Source:
protected void executeCommand() { if (getStorageDomain().getStorageType().isFileDomain()) { log.info("Reduce image isn't supported on file base domains"); setSucceeded(true); return; } if (!isReduceVolumeSupported()) { log.info("Reduce image isn't supported in {}", getStoragePool().getCompatibilityVersion()); setSucceeded(true); return; } if (!isInternalMerge()) { log.info("Reduce image isn't supported for active image merge"); setSucceeded(true); return; } getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupId())); boolean prepareImageSucceeded = false; boolean reduceImageSucceeded = false; if (!getParameters().isVmRunningOnSpm()) { log.debug("Preparing image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId()); try { prepareImage(); prepareImageSucceeded = true; } catch (EngineException e) { log.error("Failed to prepare image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId()); } } if (!getParameters().isVmRunningOnSpm() && !prepareImageSucceeded) { setSucceeded(true); return; } try { VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ReduceImage, creaeteReduceImageVDSCommandParameters()); if (vdsReturnValue.getSucceeded()) { Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand()); getTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId())); reduceImageSucceeded = true; } } catch (EngineException e) { log.error("Reducing image {}/{} failed", getParameters().getImageGroupId(), getParameters().getImageId()); } if (prepareImageSucceeded && !reduceImageSucceeded) { try { teardownImage(); } catch (EngineException e) { log.error("Failed to teardown image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId()); } } setSucceeded(true); }

Target:
protected void executeCommand() { if (getStorageDomain().getStorageType().isFileDomain()) { log.info("Reduce image isn't required for file based domains"); setSucceeded(true); return; } if (!isReduceVolumeSupported()) { log.info("Reduce image isn't supported in {}", getStoragePool().getCompatibilityVersion()); setSucceeded(true); return; } if (!isInternalMerge()) { log.info("Reduce image isn't supported for active image merge"); setSucceeded(true); return; } getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupId())); boolean prepareImageSucceeded = false; boolean reduceImageSucceeded = false; if (!getParameters().isVmRunningOnSpm()) { log.debug("Preparing image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId()); try { prepareImage(); prepareImageSucceeded = true; } catch (EngineException e) { log.error("Failed to prepare image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId()); } } if (!getParameters().isVmRunningOnSpm() && !prepareImageSucceeded) { setSucceeded(true); return; } try { VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ReduceImage, creaeteReduceImageVDSCommandParameters()); if (vdsReturnValue.getSucceeded()) { Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand()); getTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId())); reduceImageSucceeded = true; } } catch (EngineException e) { log.error("Reducing image {}/{} failed", getParameters().getImageGroupId(), getParameters().getImageId()); } if (prepareImageSucceeded && !reduceImageSucceeded) { try { teardownImage(); } catch (EngineException e) { log.error("Failed to teardown image {}/{} on the SPM", getParameters().getImageGroupId(), getParameters().getImageId()); } } setSucceeded(true); }