Source:
protected void executeCommand() { if (getVm().getstatus() != VMStatus.Down) { log.error("Cannot remove merge VM snapshot. Vm is not Down"); throw new VdcBLLException(VdcBllErrors.IRS_IMAGE_STATUS_ILLEGAL); } VmHandler.LockVm(getVm().getDynamicData(), getCompensationContext()); getParameters().setEntityId(getVmId()); List<DiskImage> destImages = null; if (getParameters().getDestVmSnapshotId() != null) { destImages = DbFacade.getInstance().getDiskImageDAO().getAllSnapshotsForVmSnapshot( getParameters().getDestVmSnapshotId().getValue()); } for (final DiskImage source : getSourceImages()) { DiskImage dest; if (getParameters().getDestVmSnapshotId() == null) { dest = DbFacade.getInstance().getDiskImageDAO().getAllSnapshotsForParent(source.getId()).get(0); } else { List<DiskImage> images = LinqUtils.filter(destImages, new Predicate<DiskImage>() { @Override public boolean eval(DiskImage a) { return a.getinternal_drive_mapping().equals(source.getinternal_drive_mapping()); } }); dest = LinqUtils.firstOrNull(images, new All<DiskImage>()); } ImagesContainterParametersBase tempVar = new ImagesContainterParametersBase(source.getId(), source.getinternal_drive_mapping(), getVmId()); tempVar.setDestinationImageId(dest.getId()); tempVar.setEntityId(getParameters().getEntityId()); ImagesContainterParametersBase p = tempVar; VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction( VdcActionType.RemoveSnapshotSingleDisk, p); getParameters().getImagesParameters().add(p); if (vdcReturnValue != null && vdcReturnValue.getInternalTaskIdList() != null) { getReturnValue().getTaskIdList().addAll(vdcReturnValue.getInternalTaskIdList()); } } setSucceeded(true); }

Target:
protected void executeCommand() { if (getVm().getstatus() != VMStatus.Down) { log.error("Cannot remove VM snapshot. Vm is not Down"); throw new VdcBLLException(VdcBllErrors.IRS_IMAGE_STATUS_ILLEGAL); } VmHandler.LockVm(getVm().getDynamicData(), getCompensationContext()); getParameters().setEntityId(getVmId()); List<DiskImage> destImages = null; if (getParameters().getDestVmSnapshotId() != null) { destImages = DbFacade.getInstance().getDiskImageDAO().getAllSnapshotsForVmSnapshot( getParameters().getDestVmSnapshotId().getValue()); } for (final DiskImage source : getSourceImages()) { DiskImage dest; if (getParameters().getDestVmSnapshotId() == null) { dest = DbFacade.getInstance().getDiskImageDAO().getAllSnapshotsForParent(source.getId()).get(0); } else { List<DiskImage> images = LinqUtils.filter(destImages, new Predicate<DiskImage>() { @Override public boolean eval(DiskImage a) { return a.getinternal_drive_mapping().equals(source.getinternal_drive_mapping()); } }); dest = LinqUtils.firstOrNull(images, new All<DiskImage>()); } ImagesContainterParametersBase tempVar = new ImagesContainterParametersBase(source.getId(), source.getinternal_drive_mapping(), getVmId()); tempVar.setDestinationImageId(dest.getId()); tempVar.setEntityId(getParameters().getEntityId()); ImagesContainterParametersBase p = tempVar; VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction( VdcActionType.RemoveSnapshotSingleDisk, p); getParameters().getImagesParameters().add(p); if (vdcReturnValue != null && vdcReturnValue.getInternalTaskIdList() != null) { getReturnValue().getTaskIdList().addAll(vdcReturnValue.getInternalTaskIdList()); } } setSucceeded(true); }