Arik Hadas has uploaded a new change for review.

Change subject: core: minor cleanup in migration related classes
......................................................................

core: minor cleanup in migration related classes

- Remove redundant setting of migrating-to-vds field in MigrateVmCommand
- Remove '_' prefix in MigrateVDSCommandParameters field names
- Fix indentation in MigrateVDSCommand
- Extract the invocation of MigrateVDSCommand from
  MigrateVmCommand#perform to separate method in order to make the
  perform method more readable

Change-Id: If7e8f60d8e9accf2618ed10fa17f74e56e0d1ae9
Signed-off-by: Arik Hadas <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MigrateVDSCommand.java
3 files changed, 31 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/72/25572/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
index 05c063b..a6225b3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
@@ -119,31 +119,28 @@
     }
 
     private void perform() {
-        getVm().setMigratingToVds(getDestinationVdsId());
-
         getParameters().setStartTime(new Date());
 
-        // Starting migration at src VDS
-        boolean connectToLunDiskSuccess = 
connectLunDisks(getDestinationVdsId());
-        if (connectToLunDiskSuccess) {
-            setActionReturnValue(Backend
-                    .getInstance()
-                    .getResourceManager()
-                    .RunAsyncVdsCommand(
-                            VDSCommandType.Migrate,
-                            createMigrateVDSCommandParameters(),
-                            this)
-                    .getReturnValue());
-        }
-        if (!connectToLunDiskSuccess || getActionReturnValue() != 
VMStatus.MigratingFrom) {
+        boolean migrateSucceeded = connectLunDisks(getDestinationVdsId()) && 
migrateVm();
+        if (!migrateSucceeded) {
             getVm().setMigreatingToPort(0);
             getVm().setMigreatingFromPort(0);
-            getVm().setMigratingToVds(null);
             throw new 
VdcBLLException(VdcBllErrors.RESOURCE_MANAGER_MIGRATION_FAILED_AT_DST);
         }
         ExecutionHandler.setAsyncJob(getExecutionContext(), true);
     }
 
+    private boolean migrateVm() {
+        setActionReturnValue(Backend.getInstance().getResourceManager()
+                .RunAsyncVdsCommand(
+                        VDSCommandType.Migrate,
+                        createMigrateVDSCommandParameters(),
+                        this)
+                .getReturnValue());
+
+        return getActionReturnValue() == VMStatus.MigratingFrom;
+    }
+
     private MigrateVDSCommandParameters createMigrateVDSCommandParameters() {
         String srcVdsHost = getVds().getHostName();
         String dstVdsHost = String.format("%1$s:%2$s",
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
index a6254ee..fb201cf 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/MigrateVDSCommandParameters.java
@@ -5,22 +5,23 @@
 import org.ovirt.engine.core.compat.Version;
 
 public class MigrateVDSCommandParameters extends VdsAndVmIDVDSParametersBase {
-    private String _srcHost;
-    private Guid _dstVdsId;
-    private String _dstHost;
-    private MigrationMethod _migrationMethod;
+    private String srcHost;
+    private Guid dstVdsId;
+    private String dstHost;
+    private MigrationMethod migrationMethod;
     private boolean tunnelMigration;
     private String dstQemu;
     private Version clusterVersion;
     private Integer migrationDowntime;
 
-    public MigrateVDSCommandParameters(Guid vdsId, Guid vmId, String srcHost, 
Guid dstVdsId, String dstHost,
-            MigrationMethod migrationMethod, boolean tunnelMigration, String 
dstQemu, Version clusterVersion, int migrationDowntime) {
+    public MigrateVDSCommandParameters(Guid vdsId, Guid vmId, String srcHost, 
Guid dstVdsId,
+            String dstHost, MigrationMethod migrationMethod, boolean 
tunnelMigration,
+            String dstQemu, Version clusterVersion, int migrationDowntime) {
         super(vdsId, vmId);
-        _srcHost = srcHost;
-        _dstVdsId = dstVdsId;
-        _dstHost = dstHost;
-        _migrationMethod = migrationMethod;
+        this.srcHost = srcHost;
+        this.dstVdsId = dstVdsId;
+        this.dstHost = dstHost;
+        this.migrationMethod = migrationMethod;
         this.tunnelMigration = tunnelMigration;
         this.dstQemu = dstQemu;
         this.clusterVersion = clusterVersion;
@@ -28,19 +29,19 @@
     }
 
     public String getSrcHost() {
-        return _srcHost;
+        return srcHost;
     }
 
     public Guid getDstVdsId() {
-        return _dstVdsId;
+        return dstVdsId;
     }
 
     public String getDstHost() {
-        return _dstHost;
+        return dstHost;
     }
 
     public MigrationMethod getMigrationMethod() {
-        return _migrationMethod;
+        return migrationMethod;
     }
 
     public boolean isTunnelMigration() {
@@ -56,7 +57,7 @@
     }
 
     public MigrateVDSCommandParameters() {
-        _migrationMethod = MigrationMethod.OFFLINE;
+        migrationMethod = MigrationMethod.OFFLINE;
     }
 
     @Override
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MigrateVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MigrateVDSCommand.java
index f491220..d0e1520 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MigrateVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MigrateVDSCommand.java
@@ -34,8 +34,8 @@
             if (vdsReturnValue.getSucceeded()) {
                 retval = VMStatus.MigratingFrom;
                 ResourceManager.getInstance().InternalSetVmStatus(vm, 
VMStatus.MigratingFrom);
-                    vm.setMigratingToVds(parameters.getDstVdsId());
-                    
ResourceManager.getInstance().AddAsyncRunningVm(parameters.getVmId());
+                vm.setMigratingToVds(parameters.getDstVdsId());
+                
ResourceManager.getInstance().AddAsyncRunningVm(parameters.getVmId());
             } else {
                 retval = vm.getStatus();
                 log.error("Failed Vm migration");


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

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