Search in sources :

Example 1 with MoveOrCopyImageGroupParameters

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

the class ImportVmTemplateCommand method moveOrCopyAllImageGroups.

@Override
protected void moveOrCopyAllImageGroups(final Guid containerID, final Iterable<DiskImage> disks) {
    TransactionSupport.executeInNewTransaction(() -> {
        for (DiskImage disk : disks) {
            Guid originalDiskId = newDiskIdForDisk.get(disk.getId()).getId();
            Guid destinationDomain = imageToDestinationDomainMap.get(originalDiskId);
            MoveOrCopyImageGroupParameters p = new MoveOrCopyImageGroupParameters(containerID, originalDiskId, newDiskIdForDisk.get(disk.getId()).getImageId(), disk.getId(), disk.getImageId(), destinationDomain, ImageOperation.Copy);
            p.setParentCommand(getActionType());
            p.setUseCopyCollapse(true);
            p.setVolumeType(disk.getVolumeType());
            p.setVolumeFormat(disk.getVolumeFormat());
            p.setCopyVolumeType(CopyVolumeType.SharedVol);
            p.setSourceDomainId(getParameters().getSourceDomainId());
            p.setForceOverride(getParameters().getForceOverride());
            p.setImportEntity(true);
            p.setEntityInfo(new EntityInfo(VdcObjectType.VmTemplate, containerID));
            p.setRevertDbOperationScope(ImageDbOperationScope.IMAGE);
            for (DiskImage diskImage : getParameters().getVmTemplate().getDiskList()) {
                if (originalDiskId.equals(diskImage.getId())) {
                    p.setQuotaId(diskImage.getQuotaId());
                    p.setDiskProfileId(diskImage.getDiskProfileId());
                    break;
                }
            }
            p.setParentParameters(getParameters());
            ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, p);
            if (!vdcRetValue.getSucceeded()) {
                throw vdcRetValue.getFault() != null ? new EngineException(vdcRetValue.getFault().getError()) : new EngineException(EngineError.ENGINE);
            }
            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) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with MoveOrCopyImageGroupParameters

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

the class ImportVmCommand method buildMoveOrCopyImageGroupParametersForDisk.

private MoveOrCopyImageGroupParameters buildMoveOrCopyImageGroupParametersForDisk(DiskImage disk, Guid containerID) {
    Guid originalDiskId = newDiskIdForDisk.get(disk.getId()).getId();
    Guid destinationDomain = imageToDestinationDomainMap.get(originalDiskId);
    MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(containerID, originalDiskId, newDiskIdForDisk.get(disk.getId()).getImageId(), disk.getId(), disk.getImageId(), destinationDomain, ImageOperation.Copy);
    params.setParentCommand(getActionType());
    params.setUseCopyCollapse(isCopyCollapseOrNoSnapshots());
    params.setCopyVolumeType(CopyVolumeType.LeafVol);
    params.setForceOverride(getParameters().getForceOverride());
    params.setSourceDomainId(getParameters().getSourceDomainId());
    params.setStoragePoolId(getParameters().getStoragePoolId());
    params.setImportEntity(true);
    params.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVm().getId()));
    params.setRevertDbOperationScope(ImageDbOperationScope.IMAGE);
    params.setQuotaId(disk.getQuotaId() != null ? disk.getQuotaId() : getParameters().getQuotaId());
    params.setDiskProfileId(disk.getDiskProfileId());
    if (getParameters().getVm().getDiskMap() != null && getParameters().getVm().getDiskMap().containsKey(originalDiskId)) {
        DiskImageBase diskImageBase = (DiskImageBase) getParameters().getVm().getDiskMap().get(originalDiskId);
        params.setVolumeType(diskImageBase.getVolumeType());
        params.setVolumeFormat(diskImageBase.getVolumeFormat());
    }
    params.setParentParameters(getParameters());
    return params;
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) DiskImageBase(org.ovirt.engine.core.common.businessentities.storage.DiskImageBase) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with MoveOrCopyImageGroupParameters

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

the class ImportVmCommand method buildMoveOrCopyImageGroupParametersForMemoryDumpImage.

private MoveOrCopyImageGroupParameters buildMoveOrCopyImageGroupParametersForMemoryDumpImage(Guid containerID, Guid storageId, Guid imageId, Guid volumeId) {
    MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(containerID, imageId, volumeId, imageId, volumeId, storageId, ImageOperation.Copy);
    params.setParentCommand(getActionType());
    params.setCopyVolumeType(CopyVolumeType.LeafVol);
    params.setForceOverride(getParameters().getForceOverride());
    params.setSourceDomainId(getParameters().getSourceDomainId());
    params.setStoragePoolId(getParameters().getStoragePoolId());
    params.setImportEntity(true);
    params.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVm().getId()));
    params.setParentParameters(getParameters());
    StorageDomainStatic storageDomain = storageDomainStaticDao.get(storageId);
    if (storageDomain.getStorageType().isBlockDomain()) {
        params.setUseCopyCollapse(true);
        params.setVolumeType(VolumeType.Preallocated);
        params.setVolumeFormat(VolumeFormat.RAW);
    }
    return params;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 4 with MoveOrCopyImageGroupParameters

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

the class CopyDiskModel method createParameters.

@Override
protected MoveOrCopyImageGroupParameters createParameters(Guid sourceStorageDomainGuid, Guid destStorageDomainGuid, DiskImage disk) {
    MoveOrCopyImageGroupParameters moveOrCopyImageGroupParameters = new MoveOrCopyImageGroupParameters(disk.getImageId(), sourceStorageDomainGuid, destStorageDomainGuid, ImageOperation.Copy);
    moveOrCopyImageGroupParameters.setImageGroupID(disk.getId());
    return moveOrCopyImageGroupParameters;
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters)

Example 5 with MoveOrCopyImageGroupParameters

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

the class AddVmAndCloneImageCommand method createCopyParameters.

protected MoveOrCopyImageGroupParameters createCopyParameters(DiskImage diskImage, Guid srcStorageDomainId, Guid srcImageGroupId, Guid srcImageId, ActionType parentCommandType) {
    MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(getVmId(), srcImageGroupId, srcImageId, diskImage.getId(), diskImage.getImageId(), diskImage.getStorageIds().get(0), ImageOperation.Copy);
    params.setAddImageDomainMapping(false);
    params.setCopyVolumeType(CopyVolumeType.LeafVol);
    params.setVolumeFormat(diskImage.getVolumeFormat());
    params.setVolumeType(diskImage.getVolumeType());
    params.setUseCopyCollapse(true);
    params.setSourceDomainId(srcStorageDomainId);
    params.setWipeAfterDelete(diskImage.isWipeAfterDelete());
    params.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId()));
    params.setParentParameters(getParameters());
    params.setParentCommand(parentCommandType);
    return params;
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

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