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