Roy Golan has uploaded a new change for review.

Change subject: core: avoid removing a vm also when migratingTo
......................................................................

core: avoid removing a vm also when migratingTo

The fix simplifies the check and states what states we CAN delete the VM
, otherwise fail canDoAction

Change-Id: I6d97fbe84a81a3a4704ed1d80d9b52da752c108a
Bug-Url: https://bugzilla.redhat.com/1136010
Signed-off-by: Roy Golan <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java
1 file changed, 11 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/45/32245/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java
index 55bff35..1e5e343 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java
@@ -192,12 +192,18 @@
     }
 
     private boolean canRemoveVm() {
-        if (isVmRunning(getVmId()) || (getVm().getStatus() == 
VMStatus.NotResponding)) {
-            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING);
+        switch (getVm().getStatus()) {
+            case Unassigned:
+            case Down:
+            case ImageIllegal:
+            case ImageLocked:
+                break;
+            case Suspended:
+                return 
failCanDoAction(VdcBllMessages.VM_CANNOT_REMOVE_VM_WHEN_STATUS_IS_NOT_DOWN);
+            default:
+                return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING);
         }
-        if (getVm().getStatus() == VMStatus.Suspended) {
-            return 
failCanDoAction(VdcBllMessages.VM_CANNOT_REMOVE_VM_WHEN_STATUS_IS_NOT_DOWN);
-        }
+
         if (isVmInPool(getVmId())) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_ATTACHED_TO_POOL);
         }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d97fbe84a81a3a4704ed1d80d9b52da752c108a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Roy Golan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to