Source:
<code>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); } if (!hasImages()) { getSnapshotDao().remove(getParameters().getSnapshotId()); setSucceeded(true); return; } TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { Snapshot snapshot = getSnapshotDao().get(getParameters().getSnapshotId()); getCompensationContext().snapshotEntityStatus(snapshot, snapshot.getStatus()); getSnapshotDao().updateStatus( getParameters().getSnapshotId(), SnapshotStatus.LOCKED); getCompensationContext().stateChanged(); return null; } }); freeLock(); getParameters().setEntityId(getVmId()); for (final DiskImage source : getSourceImages()) { DiskImage dest = getDiskImageDao().getAllSnapshotsForParent(source.getImageId()).get(0); ImagesContainterParametersBase tempVar = new ImagesContainterParametersBase(source.getImageId(), getVmId()); tempVar.setDestinationImageId(dest.getImageId()); tempVar.setEntityId(getParameters().getEntityId()); tempVar.setParentParameters(getParameters()); tempVar.setParentCommand(getActionType()); ImagesContainterParametersBase p = tempVar; VdcReturnValueBase vdcReturnValue = getBackend().runInternalAction( VdcActionType.RemoveSnapshotSingleDisk, p, ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); getParameters().getImagesParameters().add(p); if (vdcReturnValue != null && vdcReturnValue.getInternalTaskIdList() != null) { getReturnValue().getTaskIdList().addAll(vdcReturnValue.getInternalTaskIdList()); } QuotaManager.getInstance().removeQuotaFromCache(getStoragePoolId().getValue(), source.getQuotaId()); <START> QuotaManager.getInstance().removeQuotaFromCache(getStoragePoolId().getValue(), dest.getQuotaId()); <END> } setSucceeded(true); }</code><technical_language>a single call removeQuotaFromCache receives list of quota ids</technical_language>

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); } if (!hasImages()) { getSnapshotDao().remove(getParameters().getSnapshotId()); setSucceeded(true); return; } TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { Snapshot snapshot = getSnapshotDao().get(getParameters().getSnapshotId()); getCompensationContext().snapshotEntityStatus(snapshot, snapshot.getStatus()); getSnapshotDao().updateStatus( getParameters().getSnapshotId(), SnapshotStatus.LOCKED); getCompensationContext().stateChanged(); return null; } }); freeLock(); getParameters().setEntityId(getVmId()); for (final DiskImage source : getSourceImages()) { DiskImage dest = getDiskImageDao().getAllSnapshotsForParent(source.getImageId()).get(0); ImagesContainterParametersBase tempVar = new ImagesContainterParametersBase(source.getImageId(), getVmId()); tempVar.setDestinationImageId(dest.getImageId()); tempVar.setEntityId(getParameters().getEntityId()); tempVar.setParentParameters(getParameters()); tempVar.setParentCommand(getActionType()); ImagesContainterParametersBase p = tempVar; VdcReturnValueBase vdcReturnValue = getBackend().runInternalAction( VdcActionType.RemoveSnapshotSingleDisk, p, ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); getParameters().getImagesParameters().add(p); if (vdcReturnValue != null && vdcReturnValue.getInternalTaskIdList() != null) { getReturnValue().getTaskIdList().addAll(vdcReturnValue.getInternalTaskIdList()); } List<Guid> quotasToRemoveFromCache = new ArrayList<Guid>(); quotasToRemoveFromCache.add(source.getQuotaId()); quotasToRemoveFromCache.add(dest.getQuotaId()); QuotaManager.getInstance().removeQuotasFromCache(getStoragePoolId().getValue(), quotasToRemoveFromCache); } setSucceeded(true); }