ofri masad has uploaded a new change for review. Change subject: core: Fix quota calc for stateless (#848107) ......................................................................
core: Fix quota calc for stateless (#848107) https://bugzilla.redhat.com/848107 The quota claculation for stateless vm runs was wrong and the error message shown in the UI was uninformative. The calculation was fixed - the size of storage consumed from the quota is the size of the snapshot taken in order to run in stateless mode. The informative error messages are forwarded from the backend. Change-Id: I4fa99abecfb48a1fc04b7906be8167846ecc629e Signed-off-by: Ofri Masad <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java 2 files changed, 47 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/7438/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java index ea7ddfa..225155b 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java @@ -292,6 +292,9 @@ @Override public boolean validateAndSetQuota() { + if (isInternalExecution()) { + return true; + } return getQuotaManager().validateAndSetStorageQuota(getStoragePool(), getStorageQuotaListParameters(), getReturnValue().getCanDoActionMessages()); @@ -299,6 +302,9 @@ @Override public void rollbackQuota() { + if (isInternalExecution()) { + return; + } getQuotaManager().rollbackQuota(getStoragePool(), getQuotaManager().getQuotaListFromParameters(getStorageQuotaListParameters())); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java index a093c7f..2412f92 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java @@ -2,11 +2,17 @@ import org.ovirt.engine.core.bll.job.ExecutionContext; import org.ovirt.engine.core.bll.job.ExecutionHandler; +import org.ovirt.engine.core.bll.quota.QuotaManager; +import org.ovirt.engine.core.bll.quota.StorageQuotaValidationParameter; import org.ovirt.engine.core.common.action.RunVmOnceParams; import org.ovirt.engine.core.common.action.SysPrepParams; +import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.vdscommands.CreateVmVDSCommandParameters; import org.ovirt.engine.core.dal.VdcBllMessages; + +import java.util.ArrayList; +import java.util.List; public class RunVmOnceCommand<T extends RunVmOnceParams> extends RunVmCommand<T> { public RunVmOnceCommand(T runVmParams) { @@ -50,4 +56,39 @@ ExecutionHandler.endJob(executionContext, success); } + @Override + public boolean validateAndSetQuota() { + boolean quotaAcc = super.validateAndSetQuota(); + if (!quotaAcc) { + return false; + } + + return QuotaManager.getInstance().validateAndSetStorageQuota(getStoragePool(), + getStorageQuotaListParameters(), + getReturnValue().getCanDoActionMessages()); + + } + + private List<StorageQuotaValidationParameter> getStorageQuotaListParameters() { + List<StorageQuotaValidationParameter> list = new ArrayList<StorageQuotaValidationParameter>(); + for (DiskImage image : getVm().getDiskList()) { + if (image.getQuotaId() != null) { + list.add(new StorageQuotaValidationParameter(image.getQuotaId(), + image.getstorage_ids().get(0), + image.getActualSize())); + } + } + return list; + } + + @Override + public void rollbackQuota() { + super.rollbackQuota(); + QuotaManager.getInstance().decreaseStorageQuota(getStoragePool(), getStorageQuotaListParameters()); + } + + @Override + protected void compensate() { + rollbackQuota(); + } } -- To view, visit http://gerrit.ovirt.org/7438 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4fa99abecfb48a1fc04b7906be8167846ecc629e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: ofri masad <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
