use of org.ovirt.engine.core.common.action.CopyImageGroupWithDataCommandParameters in project ovirt-engine by oVirt.
the class CreateCloneOfTemplateCommand method performImageVdsmOperation.
@Override
protected boolean performImageVdsmOperation() {
setDestinationImageId(Guid.newGuid());
persistCommandIfNeeded();
newDiskImage = cloneDiskImage(getDestinationImageId());
newDiskImage.setId(Guid.newGuid());
Guid storagePoolID = newDiskImage.getStoragePoolId() != null ? newDiskImage.getStoragePoolId() : Guid.Empty;
if (isDataOperationsByHSM()) {
CopyImageGroupWithDataCommandParameters p = new CopyImageGroupWithDataCommandParameters(storagePoolID, getParameters().getStorageDomainId(), getDestinationStorageDomainId(), getDiskImage().getId(), getImage().getImageId(), newDiskImage.getId(), getDestinationImageId(), newDiskImage.getVolumeFormat(), true);
p.setParentParameters(getParameters());
p.setParentCommand(getActionType());
p.setEndProcedure(ActionParametersBase.EndProcedure.COMMAND_MANAGED);
runInternalAction(ActionType.CopyImageGroupWithData, p);
return true;
} else {
Guid taskId = persistAsyncTaskPlaceHolder(ActionType.AddVmFromTemplate);
VDSReturnValue vdsReturnValue;
try {
vdsReturnValue = runVdsCommand(VDSCommandType.CopyImage, postDeleteActionHandler.fixParameters(new CopyImageVDSCommandParameters(storagePoolID, getParameters().getStorageDomainId(), getVmTemplateId(), getDiskImage().getId(), getImage().getImageId(), newDiskImage.getId(), getDestinationImageId(), "", getDestinationStorageDomainId(), CopyVolumeType.LeafVol, newDiskImage.getVolumeFormat(), newDiskImage.getVolumeType(), getDiskImage().isWipeAfterDelete(), storageDomainDao.get(getDestinationStorageDomainId()).getDiscardAfterDelete(), false)));
} catch (EngineException e) {
log.error("Failed creating snapshot from image id '{}'", getImage().getImageId());
throw e;
}
if (vdsReturnValue.getSucceeded()) {
getTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), ActionType.AddVmFromTemplate, VdcObjectType.Storage, getParameters().getStorageDomainId(), getDestinationStorageDomainId()));
}
return vdsReturnValue.getSucceeded();
}
}
use of org.ovirt.engine.core.common.action.CopyImageGroupWithDataCommandParameters in project ovirt-engine by oVirt.
the class CopyImageGroupCommand method performStorageOperation.
private boolean performStorageOperation() {
Guid sourceDomainId = getParameters().getSourceDomainId() != null ? getParameters().getSourceDomainId() : getDiskImage().getStorageIds().get(0);
if (isUsingSPDMFlow()) {
CopyImageGroupWithDataCommandParameters p = new CopyImageGroupWithDataCommandParameters(getStorageDomain().getStoragePoolId(), sourceDomainId, getParameters().getStorageDomainId(), getParameters().getImageGroupID(), getParameters().getImageId(), getParameters().getImageGroupID(), getParameters().getImageId(), getVolumeFormatForDomain(), getParameters().getUseCopyCollapse());
p.setParentParameters(getParameters());
p.setParentCommand(getActionType());
p.setEndProcedure(EndProcedure.COMMAND_MANAGED);
p.setJobWeight(getParameters().getJobWeight());
runInternalAction(ActionType.CopyImageGroupWithData, p);
return true;
} else {
VDSReturnValue vdsReturnValue;
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
if (getParameters().getUseCopyCollapse()) {
vdsReturnValue = runVdsCommand(VDSCommandType.CopyImage, postDeleteActionHandler.fixParameters(new CopyImageVDSCommandParameters(getStorageDomain().getStoragePoolId(), sourceDomainId, getParameters().getContainerId(), getParameters().getImageGroupID(), getParameters().getImageId(), getParameters().getDestImageGroupId(), getParameters().getDestinationImageId(), "", getParameters().getStorageDomainId(), getParameters().getCopyVolumeType(), getVolumeFormatForDomain(), getParameters().getVolumeType(), isWipeAfterDelete(), getStorageDomain().getDiscardAfterDelete(), getParameters().getForceOverride())));
} else {
vdsReturnValue = runVdsCommand(VDSCommandType.MoveImageGroup, postDeleteActionHandler.fixParameters(new MoveImageGroupVDSCommandParameters(getDiskImage() != null ? getDiskImage().getStoragePoolId() : getStorageDomain().getStoragePoolId(), sourceDomainId, getDiskImage() != null ? getDiskImage().getId() : getParameters().getImageGroupID(), getParameters().getStorageDomainId(), getParameters().getContainerId(), ImageOperation.Copy, isWipeAfterDelete(), storageDomainDao.get(sourceDomainId).getDiscardAfterDelete(), getParameters().getForceOverride())));
}
if (vdsReturnValue.getSucceeded()) {
AsyncTaskCreationInfo taskCreationInfo = vdsReturnValue.getCreationInfo();
getTaskIdList().add(createTask(taskId, taskCreationInfo, getParameters().getParentCommand(), VdcObjectType.Storage, sourceDomainId, getParameters().getStorageDomainId()));
}
return vdsReturnValue.getSucceeded();
}
}
Aggregations