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