ofri masad has uploaded a new change for review.

Change subject: core: Fix storage quota release on stopStatelessVm
......................................................................

core: Fix storage quota release on stopStatelessVm

StopVmBase was defined QuotaStorageDependent and the
getQuotaStorageConsumptionParameters() was implemented to handle cases a
stateless vm is stopped (vm images are deleted).

Change-Id: I7088b94cd716bb93b2a4813963a980f4eab9e597
Signed-off-by: Ofri Masad <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
2 files changed, 22 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/70/9470/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java
index 75cc9ba..a055203 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java
@@ -6,12 +6,11 @@
 import org.ovirt.engine.core.bll.quota.QuotaVdsDependent;
 import org.ovirt.engine.core.bll.quota.QuotaVdsGroupConsumptionParameter;
 import org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter;
+import org.ovirt.engine.core.bll.quota.QuotaStorageDependent;
+import org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.common.action.VmOperationParameterBase;
-import org.ovirt.engine.core.common.businessentities.VM;
-import org.ovirt.engine.core.common.businessentities.VMStatus;
-import org.ovirt.engine.core.common.businessentities.VmDevice;
-import org.ovirt.engine.core.common.businessentities.VmDynamic;
+import org.ovirt.engine.core.common.businessentities.*;
 import org.ovirt.engine.core.common.utils.VmDeviceCommonUtils;
 import org.ovirt.engine.core.common.utils.VmDeviceType;
 import org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters;
@@ -26,7 +25,8 @@
 import org.ovirt.engine.core.utils.transaction.TransactionMethod;
 import org.ovirt.engine.core.utils.transaction.TransactionSupport;
 
-public abstract class StopVmCommandBase<T extends VmOperationParameterBase> 
extends VmOperationCommandBase<T> implements QuotaVdsDependent {
+public abstract class StopVmCommandBase<T extends VmOperationParameterBase> 
extends VmOperationCommandBase<T>
+        implements QuotaVdsDependent, QuotaStorageDependent {
     private boolean privateSuspendedVm;
 
     public StopVmCommandBase(T parameters) {
@@ -233,6 +233,22 @@
         return list;
     }
 
+    public List<QuotaConsumptionParameter> 
getQuotaStorageConsumptionParameters() {
+        List<QuotaConsumptionParameter> list = new 
ArrayList<QuotaConsumptionParameter>();
+        //if runAsStateless
+        if (getVm().getis_stateless()) {
+            for (DiskImage image : getVm().getDiskList()) {
+                if (image.getQuotaId() != null) {
+                    list.add(new 
QuotaStorageConsumptionParameter(image.getQuotaId(), null,
+                            QuotaConsumptionParameter.QuotaAction.CONSUME,
+                            image.getstorage_ids().get(0), 
image.getActualSize()));
+                }
+            }
+        }
+
+        return list;
+    }
+
     @Override
     public void addQuotaPermissionSubject(List<PermissionSubject> 
quotaPermissionList) {
         //
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
index 662516d..37e1d37 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
@@ -12,7 +12,7 @@
     AddVmFromScratch(3, ActionGroup.CREATE_VM, QuotaDependency.NONE),
     RemoveVm(4, ActionGroup.DELETE_VM, QuotaDependency.STORAGE),
     UpdateVm(5, ActionGroup.EDIT_VM_PROPERTIES, QuotaDependency.VDS_GROUP),
-    StopVm(7, ActionGroup.VM_BASIC_OPERATIONS, QuotaDependency.VDS_GROUP),
+    StopVm(7, ActionGroup.VM_BASIC_OPERATIONS, QuotaDependency.BOTH),
     ShutdownVm(8, ActionGroup.VM_BASIC_OPERATIONS, QuotaDependency.VDS_GROUP),
     ChangeDisk(9, ActionGroup.CHANGE_VM_CD, QuotaDependency.NONE),
     PauseVm(10, QuotaDependency.NONE),


--
To view, visit http://gerrit.ovirt.org/9470
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7088b94cd716bb93b2a4813963a980f4eab9e597
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

Reply via email to