Arik Hadas has uploaded a new change for review.

Change subject: core: minor cleanup in MigrateVmToServerCommand
......................................................................

core: minor cleanup in MigrateVmToServerCommand

- remove var_action and var_type settings which are already set in
  MigrateVmCommand#setActionMessageParameters
- call failCanDoAction instead of having nested if-else statements
- move comment that explains a method to be right before the method
  instead of inside the method body

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


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/18469/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmToServerCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmToServerCommand.java
index 802ab91..f31916e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmToServerCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmToServerCommand.java
@@ -16,30 +16,29 @@
     @Override
     protected boolean canDoAction() {
         VM vm = getVm();
-        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__MIGRATE);
-        addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM);
         Guid destinationId = getVdsDestinationId();
         VDS vds = DbFacade.getInstance().getVdsDao().get(destinationId);
         if (vds == null) {
-            addCanDoActionMessage(VdcBllMessages.VDS_INVALID_SERVER_ID);
-            return false;
-        } else if (vm.getRunOnVds() != null && 
vm.getRunOnVds().equals(destinationId)) {
-            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST);
-            return false;
-        } else if 
(!vm.getVdsGroupId().equals(getDestinationVds().getVdsGroupId())) {
-            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_MIGRATE_BETWEEN_TWO_CLUSTERS);
-            return false;
-        } else {
-            return super.canDoAction();
+            return failCanDoAction(VdcBllMessages.VDS_INVALID_SERVER_ID);
         }
+
+        if (vm.getRunOnVds() != null && 
vm.getRunOnVds().equals(destinationId)) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST);
+        }
+
+        if (!vm.getVdsGroupId().equals(getDestinationVds().getVdsGroupId())) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_MIGRATE_BETWEEN_TWO_CLUSTERS);
+        }
+
+        return super.canDoAction();
     }
 
+    /**
+     * In case we failed to migrate to that specific server, the VM should no 
longer be pending,
+     * and we report failure, without an attempt to rerun
+     */
     @Override
     public void rerun() {
-        /**
-         * In case we failed to migrate to that specific server, the VM should 
no longer be pending, and we
-         * report failure, without an attempt to rerun
-         */
         decreasePendingVms(getDestinationVds().getId());
         _isRerun = false;
         setSucceeded(false);


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

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