Moti Asayag has uploaded a new change for review.

Change subject: engine: Migration network should be active on src/dst
......................................................................

engine: Migration network should be active on src/dst

The migration network should be active with an IP address on
both source and destination hosts. In case the host doesn't
have the migration network configured with an IP address and
operational, it should fall-back to migrate the VM on top of
the management network.

Change-Id: I74ad1e62989eb3944542d823e85b59cbbdf40ed1
Bug-Url: https://bugzilla.redhat.com/975786
Signed-off-by: Moti Asayag <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
1 file changed, 24 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/60/19260/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 f7bc658..147fbd8 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
@@ -18,6 +18,7 @@
 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.InterfaceStatus;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
@@ -191,15 +192,31 @@
             }
         }
 
-        // Find migration ip
         if (migrationNetwork != null) {
-            final List<VdsNetworkInterface> allInterfacesForDstVds =
-                    
DbFacade.getInstance().getInterfaceDao().getAllInterfacesForVds(getDestinationVds().getId());
 
-            for (VdsNetworkInterface nic : allInterfacesForDstVds) {
-                if (migrationNetwork.getName().equals(nic.getNetworkName())) {
-                    return nic.getAddress();
-                }
+            // assure migration network is active on source host
+            if (getMigrationNetworkAddress(getVds().getId(), 
migrationNetwork.getName()) == null) {
+                return null;
+            }
+
+            // find migration IP address on destination host
+            String dstMigrationIp = 
getMigrationNetworkAddress(getDestinationVds().getId(), 
migrationNetwork.getName());
+            if (dstMigrationIp != null) {
+                return dstMigrationIp;
+            }
+        }
+
+        return null;
+    }
+
+    private String getMigrationNetworkAddress(Guid hostId, String 
migrationNetworkName) {
+        final List<VdsNetworkInterface> nics =
+                getDbFacade().getInterfaceDao().getAllInterfacesForVds(hostId);
+
+        for (VdsNetworkInterface nic : nics) {
+            if (nic.getStatistics().getStatus() == InterfaceStatus.UP
+                    && migrationNetworkName.equals(nic.getNetworkName())) {
+                return nic.getAddress();
             }
         }
 


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

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

Reply via email to