Source:
protected void executeCommand() { List<DiskImage> imageTemplates = DisksFilter.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm( getVmTemplateId())); for (DiskImage template : imageTemplates) { for (Guid domain : (Collection<Guid>)CollectionUtils.intersection(getParameters().getStorageDomainsList(), template.getStorageIds())) { ImagesContainterParametersBase tempVar = new ImagesContainterParametersBase(template.getImageId(), getVmTemplateId()); tempVar.setStorageDomainId(domain); tempVar.setStoragePoolId(template.getStoragePoolId()); tempVar.setImageGroupID(template.getId()); tempVar.setEntityInfo(getParameters().getEntityInfo()); tempVar.setWipeAfterDelete(template.isWipeAfterDelete()); tempVar.setTransactionScopeOption(TransactionScopeOption.RequiresNew); tempVar.setParentCommand(getActionType()); tempVar.setParentParameters(getParameters()); VdcReturnValueBase vdcReturnValue = runInternalActionWithTasksContext( VdcActionType.RemoveTemplateSnapshot, tempVar); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList()); } else { log.error("Can't remove image id '{}' for template id '{}' from domain id '{}' due to: {}.", template.getImageId(), getVmTemplateId(), domain, vdcReturnValue.getFault().getMessage()); } DbFacade.getInstance().getImageStorageDomainMapDao().remove( new ImageStorageDomainMapId(template.getImageId(), domain)); } DiskImage diskImage = DbFacade.getInstance().getDiskImageDao().get(template.getImageId()); if (diskImage != null) { DbFacade.getInstance().getBaseDiskDao().remove(template.getId()); DbFacade.getInstance() .getVmDeviceDao() .remove(new VmDeviceId(diskImage.getImageId(), getVmTemplateId())); DbFacade.getInstance().getImageStorageDomainMapDao().remove(diskImage.getImageId()); DbFacade.getInstance().getImageDao().remove(template.getImageId()); } } setSucceeded(true); }

Target:
protected void executeCommand() { List<DiskImage> imageTemplates = DisksFilter.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm( getVmTemplateId()), ONLY_ACTIVE); for (DiskImage template : imageTemplates) { for (Guid domain : (Collection<Guid>)CollectionUtils.intersection(getParameters().getStorageDomainsList(), template.getStorageIds())) { ImagesContainterParametersBase tempVar = new ImagesContainterParametersBase(template.getImageId(), getVmTemplateId()); tempVar.setStorageDomainId(domain); tempVar.setStoragePoolId(template.getStoragePoolId()); tempVar.setImageGroupID(template.getId()); tempVar.setEntityInfo(getParameters().getEntityInfo()); tempVar.setWipeAfterDelete(template.isWipeAfterDelete()); tempVar.setTransactionScopeOption(TransactionScopeOption.RequiresNew); tempVar.setParentCommand(getActionType()); tempVar.setParentParameters(getParameters()); VdcReturnValueBase vdcReturnValue = runInternalActionWithTasksContext( VdcActionType.RemoveTemplateSnapshot, tempVar); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList()); } else { log.error("Can't remove image id '{}' for template id '{}' from domain id '{}' due to: {}.", template.getImageId(), getVmTemplateId(), domain, vdcReturnValue.getFault().getMessage()); } DbFacade.getInstance().getImageStorageDomainMapDao().remove( new ImageStorageDomainMapId(template.getImageId(), domain)); } DiskImage diskImage = DbFacade.getInstance().getDiskImageDao().get(template.getImageId()); if (diskImage != null) { DbFacade.getInstance().getBaseDiskDao().remove(template.getId()); DbFacade.getInstance() .getVmDeviceDao() .remove(new VmDeviceId(diskImage.getImageId(), getVmTemplateId())); DbFacade.getInstance().getImageStorageDomainMapDao().remove(diskImage.getImageId()); DbFacade.getInstance().getImageDao().remove(template.getImageId()); } } setSucceeded(true); }