Alona Kaplan has uploaded a new change for review.

Change subject: engine: Extending migrate verb with an additional parameter- 
"dstqemo"
......................................................................

engine: Extending migrate verb with an additional parameter- "dstqemo"

The dstqemo will contain the dedicated migration address of destination
host (the ip of the cluster-migration network on the destination host).
If there is no migration network in the cluster or the destination host
doesn't contain the migration network, "dstqemo" won't be sent to the
vdsm.
(vdsm will use the management network sent on "dst" pararamer for the
migration).

Change-Id: Ic460c2b8ebfb870a610f5816643d9855495dc7b1
Signed-off-by: Alona Kaplan <[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/vdsbroker/MigrateBrokerVDSCommand.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
4 files changed, 59 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/13064/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 45ea7c4..c6b6a33 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
@@ -1,6 +1,7 @@
 package org.ovirt.engine.core.bll;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
 import org.ovirt.engine.core.bll.snapshots.SnapshotsValidator;
@@ -13,6 +14,9 @@
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
+import org.ovirt.engine.core.common.businessentities.network.Network;
+import org.ovirt.engine.core.common.businessentities.network.NetworkCluster;
+import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.errors.VdcBllErrors;
 import 
org.ovirt.engine.core.common.vdscommands.MigrateStatusVDSCommandParameters;
@@ -125,6 +129,7 @@
                     getVm().getTunnelMigration() != null ? 
getVm().getTunnelMigration()
                             : getVdsGroup().isTunnelMigration();
         }
+
         // Starting migration at src VDS
         boolean connectToLunDiskSuccess = connectLunDisks(_vdsDestinationId);
         if (connectToLunDiskSuccess) {
@@ -134,7 +139,9 @@
                     .RunAsyncVdsCommand(
                             VDSCommandType.Migrate,
                             new MigrateVDSCommandParameters(getVdsId(), 
getVmId(), srcVdsHost, _vdsDestinationId,
-                                    dstVdsHost, MigrationMethod.ONLINE, 
tunnelMigration), this).getReturnValue());
+                                    dstVdsHost, MigrationMethod.ONLINE, 
tunnelMigration, getMigrationNetworkIp()),
+                            this)
+                    .getReturnValue());
         }
         if (!connectToLunDiskSuccess || (VMStatus) getActionReturnValue() != 
VMStatus.MigratingFrom) {
             getVm().setMigreatingToPort(0);
@@ -145,6 +152,44 @@
         ExecutionHandler.setAsyncJob(getExecutionContext(), true);
     }
 
+    private String getMigrationNetworkIp() {
+        // Find migrationNetworkCluster
+        List<NetworkCluster> all = DbFacade.getInstance()
+                
.getNetworkClusterDao().getAllForCluster(getVm().getVdsGroupId());
+        NetworkCluster migrationNetworkCluster = null;
+
+        for (NetworkCluster tempNetworkCluster : all) {
+            if (tempNetworkCluster.isMigration()) {
+                migrationNetworkCluster = tempNetworkCluster;
+                break;
+            }
+        }
+
+        // Find migration network
+        Network migrationNetwork = null;
+        if (migrationNetworkCluster != null) {
+            migrationNetwork = DbFacade.getInstance().getNetworkDao()
+                    .get(migrationNetworkCluster.getNetworkId());
+        }
+
+        // Find migration ip
+        String migrationNetworkName = migrationNetwork == null ? null : 
migrationNetwork.getName();
+        String migrationIp = null;
+        if (migrationNetworkName != null) {
+
+            final List<VdsNetworkInterface> allInterfacesForDstVds =
+                    
DbFacade.getInstance().getInterfaceDao().getAllInterfacesForVds(getDestinationVds().getId());
+
+            for (VdsNetworkInterface nic : allInterfacesForDstVds) {
+                if (nic.getNetworkName() != null && 
nic.getNetworkName().equals(migrationNetworkName)) {
+                    migrationIp = nic.getAddress();
+                }
+            }
+        }
+
+        return migrationIp;
+    }
+
     /**
      * command succeeded and VM is up => migration done
      * command succeeded and VM is not up => migration started
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 7da72cb..7b6dbd7 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
@@ -9,15 +9,17 @@
     private String _dstHost;
     private MigrationMethod _migrationMethod = MigrationMethod.forValue(0);
     private Boolean tunnelMigration;
+    private String dstQemu;
 
     public MigrateVDSCommandParameters(Guid vdsId, Guid vmId, String srcHost, 
Guid dstVdsId, String dstHost,
-            MigrationMethod migrationMethod, Boolean tunnelMigration) {
+            MigrationMethod migrationMethod, Boolean tunnelMigration, String 
dstQemu) {
         super(vdsId, vmId);
         _srcHost = srcHost;
         _dstVdsId = dstVdsId;
         _dstHost = dstHost;
         _migrationMethod = migrationMethod;
         this.tunnelMigration = tunnelMigration;
+        this.dstQemu = dstQemu;
     }
 
     public String getSrcHost() {
@@ -40,6 +42,10 @@
         return tunnelMigration;
     }
 
+    public String getDstQemu() {
+        return dstQemu;
+    }
+
     public MigrateVDSCommandParameters() {
     }
 
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateBrokerVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateBrokerVDSCommand.java
index e4d76eb..0349a09 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateBrokerVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateBrokerVDSCommand.java
@@ -6,7 +6,7 @@
 import org.ovirt.engine.core.common.vdscommands.MigrateVDSCommandParameters;
 
 public class MigrateBrokerVDSCommand<P extends MigrateVDSCommandParameters> 
extends VdsBrokerCommand<P> {
-    private Map<String, String> migrationInfo;
+    private final Map<String, String> migrationInfo;
 
     public MigrateBrokerVDSCommand(P parameters) {
         super(parameters);
@@ -21,6 +21,10 @@
         if (parameters.getTunnelMigration() != null) {
             migrationInfo.put(VdsProperties.TUNNELED, 
parameters.getTunnelMigration().toString());
         }
+
+        if (parameters.getDstQemu() != null) {
+            migrationInfo.put(VdsProperties.dstQuemo, parameters.getDstQemu());
+        }
     }
 
     @Override
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
index 41c90d8..57eb169 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
@@ -254,6 +254,7 @@
     public static final String domains = "storageDomains";
     public static final String hooks = "hooks";
     public static final String TUNNELED = "tunneled";
+    public static final String dstQuemo = "dstqemu";
 
     // storage domains
     public static final String code = "code";


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

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

Reply via email to