Source:
protected void ExecuteVmCommand() { Set<Guid> mImagesToBeRemoved = new HashSet<Guid>(); List<DiskImage> images = getParameters().Images; if (images == null) { images = ImagesHandler.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm(getVmId()), true, false); } for (DiskImage image : images) { if (Boolean.TRUE.equals(image.getactive())) { mImagesToBeRemoved.add(image.getImageId()); } } boolean noImagesRemovedYet = true; for (final DiskImage image : images) { if (mImagesToBeRemoved.contains(image.getImageId())) { RemoveImageParameters tempVar = new RemoveImageParameters(image.getImageId()); tempVar.setParentCommand(getParameters().getParentCommand()); tempVar.setParentParemeters(getParameters().getParentParameters()); tempVar.setDiskImage(image); tempVar.setEntityId(getParameters().getEntityId()); tempVar.setForceDelete(getParameters().getForceDelete()); tempVar.setParentParemeters(getParameters()); VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction(VdcActionType.RemoveImage, tempVar, ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalTaskIdList().addAll(vdcReturnValue.getInternalTaskIdList()); } else { if (noImagesRemovedYet) { setSucceeded(false); getReturnValue().setFault(vdcReturnValue.getFault()); return; } log.errorFormat("Can't remove image id: {0} for VM id: {1} due to: {2}. Image will be set at illegal state with no snapshot id.", image.getImageId(), getParameters().getVmId(), vdcReturnValue.getFault().getMessage()); TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Object>() { @Override public Object runInTransaction() { updateDiskImagesToIllegal(image); return true; } }); } noImagesRemovedYet = false; } } setSucceeded(true); }

Target:
protected void ExecuteVmCommand() { Set<Guid> mImagesToBeRemoved = new HashSet<Guid>(); List<DiskImage> images = getParameters().Images; if (images == null) { images = ImagesHandler.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm(getVmId()), true, false); } for (DiskImage image : images) { if (Boolean.TRUE.equals(image.getactive())) { mImagesToBeRemoved.add(image.getImageId()); } } boolean noImagesRemovedYet = true; for (DiskImage image : images) { if (mImagesToBeRemoved.contains(image.getImageId())) { RemoveImageParameters tempVar = new RemoveImageParameters(image.getImageId()); tempVar.setParentCommand(getParameters().getParentCommand()); tempVar.setParentParemeters(getParameters().getParentParameters()); tempVar.setDiskImage(image); tempVar.setEntityId(getParameters().getEntityId()); tempVar.setForceDelete(getParameters().getForceDelete()); tempVar.setParentParemeters(getParameters()); VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction(VdcActionType.RemoveImage, tempVar, ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalTaskIdList().addAll(vdcReturnValue.getInternalTaskIdList()); } else { if (noImagesRemovedYet) { setSucceeded(false); getReturnValue().setFault(vdcReturnValue.getFault()); return; } log.errorFormat("Can't remove image id: {0} for VM id: {1} due to: {2}. Image will be set at illegal state with no snapshot id.", image.getImageId(), getParameters().getVmId(), vdcReturnValue.getFault().getMessage()); TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Object>() { @Override public Object runInTransaction() { updateDiskImagesToIllegal(image); return true; } }); } noImagesRemovedYet = false; } } setSucceeded(true); }