Search in sources :

Example 6 with MoveOrCopyImageGroupParameters

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

the class AddVmAndCloneImageCommand method copyDiskImage.

protected void copyDiskImage(DiskImage diskImage, Guid srcStorageDomainId, Guid destStorageDomainId, Guid diskProfileId, ActionType parentCommandType) {
    DiskImage newDiskImage = imagesHandler.cloneDiskImage(destStorageDomainId, Guid.newGuid(), Guid.newGuid(), diskImage, diskProfileId, getVmSnapshotId(), diskInfoDestinationMap != null ? diskInfoDestinationMap.get(diskImage.getId()) : null);
    ImagesHandler.setDiskAlias(newDiskImage, getVm());
    MoveOrCopyImageGroupParameters parameters = createCopyParameters(newDiskImage, srcStorageDomainId, diskImage.getId(), diskImage.getImageId(), parentCommandType);
    parameters.setRevertDbOperationScope(ImageDbOperationScope.IMAGE);
    ActionReturnValue result = executeChildCopyingCommand(parameters);
    handleCopyResult(diskImage, newDiskImage, result);
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 7 with MoveOrCopyImageGroupParameters

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

the class ExportVmTemplateCommand method moveOrCopyAllImageGroups.

@Override
protected void moveOrCopyAllImageGroups(final Guid containerID, final Iterable<DiskImage> disks) {
    TransactionSupport.executeInNewTransaction(() -> {
        for (DiskImage disk : disks) {
            // we force export template image to COW+Sparse but we don't update
            // the ovf so the import
            // will set the original format
            MoveOrCopyImageGroupParameters p = new MoveOrCopyImageGroupParameters(containerID, disk.getId(), disk.getImageId(), getParameters().getStorageDomainId(), ImageOperation.Copy);
            p.setParentCommand(getActionType());
            p.setParentParameters(getParameters());
            p.setEntityInfo(getParameters().getEntityInfo());
            p.setUseCopyCollapse(true);
            p.setCopyVolumeType(CopyVolumeType.SharedVol);
            p.setVolumeFormat(disk.getVolumeFormat());
            p.setVolumeType(disk.getVolumeType());
            p.setForceOverride(getParameters().getForceOverride());
            p.setRevertDbOperationScope(ImageDbOperationScope.NONE);
            p.setShouldLockImageOnRevert(false);
            p.setSourceDomainId(imageFromSourceDomainMap.get(disk.getId()).getStorageIds().get(0));
            ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, p);
            if (!vdcRetValue.getSucceeded()) {
                throw new EngineException(vdcRetValue.getFault().getError(), vdcRetValue.getFault().getMessage());
            }
            getReturnValue().getVdsmTaskIdList().addAll(vdcRetValue.getInternalVdsmTaskIdList());
        }
        return null;
    });
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 8 with MoveOrCopyImageGroupParameters

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

the class MoveOrCopyDiskCommand method prepareChildParameters.

private MoveOrCopyImageGroupParameters prepareChildParameters() {
    MoveOrCopyImageGroupParameters parameters = new MoveOrCopyImageGroupParameters(getParameters());
    if (parameters.getOperation() == ImageOperation.Copy) {
        parameters.setUseCopyCollapse(true);
        parameters.setAddImageDomainMapping(true);
        parameters.setShouldLockImageOnRevert(false);
        if (!isTemplate()) {
            prepareCopyNotTemplate(parameters);
            parameters.setShouldLockImageOnRevert(true);
            parameters.setRevertDbOperationScope(ImageDbOperationScope.IMAGE);
        }
    } else {
        parameters.setUseCopyCollapse(false);
    }
    if (parameters.getOperation() == ImageOperation.Move || isTemplate()) {
        parameters.setDestinationImageId(getImageId());
        parameters.setImageGroupID(getImageGroupId());
        parameters.setDestImageGroupId(getImageGroupId());
    }
    parameters.setVolumeFormat(getDiskImage().getVolumeFormat());
    parameters.setVolumeType(getDiskImage().getVolumeType());
    if (isTemplate()) {
        parameters.setCopyVolumeType(CopyVolumeType.SharedVol);
    } else {
        parameters.setCopyVolumeType(CopyVolumeType.LeafVol);
    }
    parameters.setParentCommand(getActionType());
    parameters.setParentParameters(getParameters());
    parameters.setDiskProfileId(getImage().getDiskProfileId());
    parameters.setJobWeight(Job.MAX_WEIGHT);
    return parameters;
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters)

Example 9 with MoveOrCopyImageGroupParameters

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

the class CreateAllOvaDisksCommand method buildMoveOrCopyImageGroupParametersForDisk.

private MoveOrCopyImageGroupParameters buildMoveOrCopyImageGroupParametersForDisk(DiskImage source, DiskImage destination) {
    MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(getParameters().getEntityId(), source.getId(), source.getImageId(), destination.getId(), destination.getImageId(), // TODO: change
    source.getStorageIds().get(0), ImageOperation.Copy);
    params.setParentCommand(getActionType());
    params.setCopyVolumeType(CopyVolumeType.LeafVol);
    params.setForceOverride(true);
    params.setSourceDomainId(source.getStorageIds().get(0));
    params.setStoragePoolId(source.getStoragePoolId());
    params.setImportEntity(true);
    params.setParentParameters(getParameters());
    params.setUseCopyCollapse(true);
    params.setVolumeType(VolumeType.Sparse);
    params.setVolumeFormat(VolumeFormat.COW);
    return params;
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters)

Example 10 with MoveOrCopyImageGroupParameters

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

the class MoveOrCopyDiskCommand method executeCommand.

@Override
protected void executeCommand() {
    if (isUnregisteredDiskExistsForCopyTemplate()) {
        addDiskMapping();
        return;
    }
    MoveOrCopyImageGroupParameters p = prepareChildParameters();
    ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(getImagesActionType(), p);
    if (!vdcRetValue.getSucceeded()) {
        setSucceeded(false);
        getReturnValue().setFault(vdcRetValue.getFault());
    } else {
        setSucceeded(true);
        if (isCopyOperation() && !isTemplate()) {
            imagesHandler.addDiskImageWithNoVmDevice(getImage());
        }
    }
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Aggregations

MoveOrCopyImageGroupParameters (org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters)17 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)5 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)4 Guid (org.ovirt.engine.core.compat.Guid)4 Disk (org.ovirt.engine.api.model.Disk)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 DiskImageBase (org.ovirt.engine.core.common.businessentities.storage.DiskImageBase)1