Arik Hadas has uploaded a new change for review.

Change subject: core: change the order of canDoAction checks on hibernate
......................................................................

core: change the order of canDoAction checks on hibernate

We check if the VM is part of pool after checking if the VM is
stateless. Since every VM in pool is stateless, we'll never get to this
check. This patch change the order of these checks, to get the specific
error for the case where the VM is part of pool.

Change-Id: Ie9b98e797ad3f38f19aea45be2f7fe8d1a7635a8
Signed-off-by: Arik Hadas <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java
1 file changed, 14 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/28899/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java
index 99530b2..43658a6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java
@@ -251,24 +251,30 @@
         if (vmStatus == VMStatus.WaitForLaunch || vmStatus == 
VMStatus.NotResponding) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL, 
LocalizedVmStatus.from(vmStatus));
         }
+
         if (vmStatus != VMStatus.Up) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_NOT_UP);
         }
+
         if (TaskManagerUtil.entityHasTasks(getVmId())) {
             return 
failCanDoAction(VdcBllMessages.VM_CANNOT_SUSPENDE_HAS_RUNNING_TASKS);
         }
+
+        if (getVm().getVmPoolId() != null) {
+            return 
failCanDoAction(VdcBllMessages.VM_CANNOT_SUSPEND_VM_FROM_POOL);
+        }
+
         // check if vm has stateless images in db in case vm was run once as 
stateless
         // (then isStateless is false)
         if (getVm().isStateless() ||
                 DbFacade.getInstance().getSnapshotDao().exists(getVmId(), 
SnapshotType.STATELESS)) {
             return 
failCanDoAction(VdcBllMessages.VM_CANNOT_SUSPEND_STATELESS_VM);
         }
-        if (getVm().getVmPoolId() != null) {
-            return 
failCanDoAction(VdcBllMessages.VM_CANNOT_SUSPEND_VM_FROM_POOL);
-        }
+
         if (getStorageDomainId().equals(Guid.Empty)) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_SUITABLE_DOMAIN_FOUND);
         }
+
         return true;
     }
 
@@ -303,7 +309,7 @@
                 // start here another tasks.
 
                 log.warnFormat(
-                        "HibernateVmCommand::EndSuccessfully: Vm '{0}' is not 
in 'PreparingForHibernate' status, but in '{1}' status - not performing 
Hibernate.",
+                        "VM '{0}' is not in 'PreparingForHibernate' status, 
but in '{1}' status - not performing Hibernate.",
                         getVm().getName(),
                         getVm().getStatus());
                 getReturnValue().setEndActionTryAgain(false);
@@ -311,7 +317,7 @@
 
             else if (getVm().getRunOnVds() == null) {
                 log.warnFormat(
-                        "HibernateVmCommand::EndSuccessfully: Vm '{0}' doesn't 
have 'run_on_vds' value - cannot Hibernate.",
+                        "VM '{0}' doesn't have 'run_on_vds' value - cannot 
Hibernate.",
                         getVm().getName());
                 getReturnValue().setEndActionTryAgain(false);
             }
@@ -339,7 +345,7 @@
         }
 
         else {
-            log.warn("HibernateVmCommand::EndSuccessfully: Vm is null - not 
performing full endAction.");
+            log.warn("VM is null - not performing full endAction.");
             setSucceeded(true);
         }
     }
@@ -364,7 +370,7 @@
 
             else {
                 log.warnFormat(
-                        "HibernateVmCommand::endWithFailure: Vm '{0}' doesn't 
have 'run_on_vds' value - not clearing 'hibernation_vol_handle' info.",
+                        "VM '{0}' doesn't have 'run_on_vds' value - not 
clearing 'hibernation_vol_handle' info.",
                         getVm().getName());
 
                 getReturnValue().setEndActionTryAgain(false);
@@ -373,7 +379,7 @@
 
         else {
             setCommandShouldBeLogged(false);
-            log.warn("HibernateVmCommand::endWithFailure: Vm is null - not 
performing full endAction.");
+            log.warn("VM is null - not performing full endAction.");
             setSucceeded(true);
         }
     }


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

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

Reply via email to