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/947965
Signed-off-by: Roy Golan <rgo...@redhat.com>
(cherry picked from commit a957c4825f1af750ae641d0c9d3abe7dee151110)
---
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/36/32236/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 0a584bf..d14f996 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
@@ -172,12 +172,18 @@
             return false;
         }
 
-        if (getVm().isRunningOrPaused() || getVm().getStatus() == 
VMStatus.Unknown || 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 (getVm().getVmPoolId() != null) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_ATTACHED_TO_POOL);
         }


-- 
To view, visit http://gerrit.ovirt.org/32236
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.5
Gerrit-Owner: Roy Golan <rgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to