Alona Kaplan has uploaded a new change for review.

Change subject: engine: Host with no display network should not be selected to 
run VMs
......................................................................

engine: Host with no display network should not be selected to run VMs

If the cluster's display network is not attached to the host, the host
shouldn't be selected/eligible to run VMs in that cluster.

Change-Id: Ie90e2821f2299be85b1d4c9a6f064a4053f93e73
Bug-Url: https://bugzilla.redhat.com/949434
Signed-off-by: Alona Kaplan <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
6 files changed, 56 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/27/13727/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
index 4f221c7..f3b9ec8 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
@@ -312,6 +312,17 @@
 
                 @Override
                 public VdcBllMessages validate(VDS vds, StringBuilder sb, 
boolean isMigrate) {
+                    if (!isDisplayNetworkAvailable(vds)) {
+                        sb.append("is missing the cluster's display network");
+                        return 
VdcBllMessages.ACTION_TYPE_FAILED_MISSING_DISPLAY_NETWORK;
+                    }
+                    return null;
+                }
+            });
+            add(new HostValidator() {
+
+                @Override
+                public VdcBllMessages validate(VDS vds, StringBuilder sb, 
boolean isMigrate) {
                     if (isVdsFailedToRunVm(vds.getId())) {
                         sb.append("have failed running this VM in the current 
selection cycle");
                         return 
VdcBllMessages.ACTION_TYPE_FAILED_VDS_VM_CLUSTER;
@@ -378,6 +389,44 @@
                 .<Integer> 
GetValue(ConfigValues.BlockMigrationOnSwapUsagePercentage);
     }
 
+    /**
+     * Determines whether the cluster's display network is defined on the vds.
+     *
+     * @param vds
+     *            The VDS.
+     * @return <c>true</c> if the cluster's display network is defined on the 
vds; otherwise, <c>false</c>.
+     */
+    private boolean isDisplayNetworkAvailable(VDS vds) {
+        Network displayNetwork = null;
+
+        // Find the cluster's display network
+        List<Network> allNetworksInCluster =
+                
DbFacade.getInstance().getNetworkDao().getAllForCluster(vds.getVdsGroupId());
+
+        for (Network tempNetwork : allNetworksInCluster) {
+            if (tempNetwork.getCluster().isDisplay()) {
+                displayNetwork = tempNetwork;
+                break;
+            }
+        }
+
+        if (displayNetwork == null) {
+            return true;
+        }
+
+        // Check if display network attached to vds
+        final List<VdsNetworkInterface> allInterfacesForVds =
+                
DbFacade.getInstance().getInterfaceDao().getAllInterfacesForVds(vds.getId());
+
+        for (VdsNetworkInterface nic : allInterfacesForVds) {
+            if (displayNetwork.getName().equals(nic.getNetworkName())) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     private Guid getVdsToRunOn(Iterable<VDS> vdss, boolean isMigrate) {
         StringBuilder sb = new StringBuilder();
         final List<VDS> readyToRun = new ArrayList<VDS>();
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
index 7e63b63..a0f82c2 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
@@ -135,6 +135,7 @@
     ACTION_TYPE_FAILED_VDS_VM_SWAP,
     ACTION_TYPE_FAILED_VDS_VM_CPUS,
     ACTION_TYPE_FAILED_VDS_VM_NETWORKS,
+    ACTION_TYPE_FAILED_MISSING_DISPLAY_NETWORK,
     ACTION_TYPE_FAILED_NO_VDS_AVAILABLE_IN_CLUSTER,
     ACTION_TYPE_FAILED_CANNOT_REMOVE_IMAGE_TEMPLATE,
     ACTION_TYPE_FAILED_CANNOT_REMOVE_ACTIVE_IMAGE,
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index a9759af..1842d05 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -178,6 +178,7 @@
 ACTION_TYPE_FAILED_VDS_VM_MEMORY=Cannot ${action} ${type}. There are no 
available running Hosts with sufficient memory in VM's Cluster .
 ACTION_TYPE_FAILED_VDS_VM_CPUS=Cannot ${action} ${type}. There are no 
available running Hosts with enough cores in VM's Cluster .
 ACTION_TYPE_FAILED_VDS_VM_NETWORKS=Cannot ${action} ${type}. There are no 
available running Hosts with all the networks used by the VM.
+ACTION_TYPE_FAILED_MISSING_DISPLAY_NETWORK=Cannot ${action} ${type}. There are 
no available running Hosts with the cluster's display network.
 CANNOT_MAINTENANCE_VDS_RUN_VMS_NO_OTHER_RUNNING_VDS=The following Hosts have 
running VMs and cannot be switched to maintenance mode: ${HostsList}.
 Please ensure that the following Clusters have at least one Host in UP state: 
${ClustersList}.
 ACTION_TYPE_FAILED_VDS_VM_VERSION=Cannot ${action} ${type}. VM's tools version 
(${toolsVersion}) mismatch with the Host's (${serverVersion}) version.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 2b91bbb..dd2c9ea 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -475,6 +475,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. There are no available 
running Hosts with all the networks used by the VM.")
     String ACTION_TYPE_FAILED_VDS_VM_NETWORKS();
 
+    @DefaultStringValue("Cannot ${action} ${type}. There are no available 
running Hosts with the cluster's display network.")
+    String ACTION_TYPE_FAILED_MISSING_DISPLAY_NETWORK();
+
     @DefaultStringValue("The following Hosts have running VMs and cannot be 
switched to maintenance mode: ${HostsList}.Please ensure that the following 
Clusters have at least one Host in UP state: ${ClustersList}.")
     String CANNOT_MAINTENANCE_VDS_RUN_VMS_NO_OTHER_RUNNING_VDS();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 3ce4e3b..2a2d8b1 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -177,6 +177,7 @@
 ACTION_TYPE_FAILED_VDS_VM_MEMORY=Cannot ${action} ${type}. There are no 
available running Hosts with sufficient memory in VM's Cluster .
 ACTION_TYPE_FAILED_VDS_VM_CPUS=Cannot ${action} ${type}. There are no 
available running Hosts with enough cores in VM's Cluster .
 ACTION_TYPE_FAILED_VDS_VM_NETWORKS=Cannot ${action} ${type}. There are no 
available running Hosts with all the networks used by the VM.
+ACTION_TYPE_FAILED_MISSING_DISPLAY_NETWORK=Cannot ${action} ${type}. There are 
no available running Hosts with the cluster's display network.
 CANNOT_MAINTENANCE_VDS_RUN_VMS_NO_OTHER_RUNNING_VDS=The following Hosts have 
running VMs and cannot be switched to maintenance mode: ${HostsList}.
 Please ensure that the following Clusters have at least one Host in UP state: 
${ClustersList}.
 ACTION_TYPE_FAILED_VDS_VM_VERSION=Cannot ${action} ${type}. VM's tools version 
(${toolsVersion}) mismatch with the Host's (${serverVersion}) version.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 346e84d..d4ef84e 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -175,6 +175,7 @@
 ACTION_TYPE_FAILED_VDS_VM_MEMORY=Cannot ${action} ${type}. There are no 
available running Hosts with sufficient memory in VM's Cluster .
 ACTION_TYPE_FAILED_VDS_VM_CPUS=Cannot ${action} ${type}. There are no 
available running Hosts with enough cores in VM's Cluster .
 ACTION_TYPE_FAILED_VDS_VM_NETWORKS=Cannot ${action} ${type}. There are no 
available running Hosts with all the networks used by the VM.
+ACTION_TYPE_FAILED_MISSING_DISPLAY_NETWORK=Cannot ${action} ${type}. There are 
no available running Hosts with the cluster's display network.
 CANNOT_MAINTENANCE_VDS_RUN_VMS_NO_OTHER_RUNNING_VDS=The following Hosts have 
running VMs and cannot be switched to maintenance mode: ${HostsList}.
 Please ensure that the following Clusters have at least one Host in UP state: 
${ClustersList}.
 ACTION_TYPE_FAILED_VDS_VM_VERSION=Cannot ${action} ${type}. VM's tools version 
(${toolsVersion}) mismatch with the Host's (${serverVersion}) version.


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

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