Source:
protected void executeCommand() { getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupId())); boolean prepareImageSucceeded = false; if (!getParameters().isVmRunningOnSpm()) { log.debug("Preparing image on the SPM", getParameters().getImageId()); try { imagesHandler.prepareImage(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroupId(), getParameters().getImageId(), getParameters().getSpmId()); prepareImageSucceeded = true; } catch (EngineException e) { log.error("Failed to prepare image on the SPM", getParameters().getImageId()); } } if (!getParameters().isVmRunningOnSpm() && !prepareImageSucceeded) { log.error("Image prepare failed on the SPM, hence reduce will not be performed"); return; } try { ReduceImageVDSCommandParameters parameters = new ReduceImageVDSCommandParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroupId(), getParameters().getImageId(), getParameters().isAllowActive()); VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ReduceImage, parameters); if (vdsReturnValue.getSucceeded()) { Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand()); getTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId())); } } catch (EngineException e) { log.error("Reducing image failed", getParameters().getImageId()); } setSucceeded(true); }

Target:
protected void executeCommand() { getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupId())); boolean prepareImageSucceeded = false; if (!getParameters().isVmRunningOnSpm()) { log.debug("Preparing image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId()); try { imagesHandler.prepareImage(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroupId(), getParameters().getImageId(), getParameters().getSpmId()); prepareImageSucceeded = true; } catch (EngineException e) { log.error("Failed to prepare image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId()); } } if (!getParameters().isVmRunningOnSpm() && !prepareImageSucceeded) { log.error("Image prepare failed on the SPM, hence reduce will not be performed"); return; } try { ReduceImageVDSCommandParameters parameters = new ReduceImageVDSCommandParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getImageGroupId(), getParameters().getImageId(), getParameters().isAllowActive()); VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ReduceImage, parameters); if (vdsReturnValue.getSucceeded()) { Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand()); getTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId())); } } catch (EngineException e) { log.error("Reducing image {}/{} failed", getParameters().getImageGroupId(), getParameters().getImageId()); } setSucceeded(true); }