Oved Ourfali has uploaded a new change for review.

Change subject: WIP core: adding a filter policy for CPU level
......................................................................

WIP core: adding a filter policy for CPU level

Change-Id: Ib42b803fe0d2e9389d10196cd44c3fd21342927f
Bug-Url: https://bugzilla.redhat.com/1006209
Signed-off-by: Oved Ourfali <oourf...@redhat.com>
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/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, 49 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/63/19563/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
new file mode 100644
index 0000000..590eeb4
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
@@ -0,0 +1,42 @@
+package org.ovirt.engine.core.bll.scheduling.policyunits;
+
+import org.apache.commons.lang.StringUtils;
+import org.ovirt.engine.core.bll.CpuFlagsManagerHandler;
+import org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl;
+import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.core.common.errors.VdcBllMessages;
+import org.ovirt.engine.core.common.scheduling.PolicyUnit;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class CpuLevelFilterPolicyUnit extends PolicyUnitImpl {
+    public CpuLevelFilterPolicyUnit(PolicyUnit policyUnit) {
+        super(policyUnit);
+    }
+
+    @Override
+    public List<VDS> filter(List<VDS> hosts, VM vm, Map<String, String> 
parameters, List<String> messages) {
+        if (StringUtils.isNotEmpty(vm.getCpuName())) {
+            List<VDS> hostsToRunOn = new ArrayList<VDS>();
+            for (VDS host : hosts) {
+                int compareResult = 
CpuFlagsManagerHandler.compareCpuLevels(vm.getCpuName(), 
host.getCpuName().getCpuName(), vm.getVdsGroupCompatibilityVersion());
+                if (compareResult >= 0) {
+                    hostsToRunOn.add(host);
+                } else {
+                    
messages.add(VdcBllMessages.ACTION_TYPE_FAILED_VDS_VM_CPU_LEVEL.toString());
+                    log.debugFormat("Host {0} has CPU level ({1}) which is 
lower than the CPU level the VM was run with ({2})",
+                            host.getName(),
+                            host.getCpuName(),
+                            vm.getCpuName());
+                }
+            }
+
+            return hostsToRunOn;
+        } else {
+            return hosts;
+        }
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index 51c74ad..02cb0c9 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -178,6 +178,7 @@
     ACTION_TYPE_FAILED_VDS_VM_VERSION(ErrorType.INCOMPATIBLE_VERSION),
     ACTION_TYPE_FAILED_VDS_VM_SWAP(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_VDS_VM_CPUS(ErrorType.CONFLICT),
+    ACTION_TYPE_FAILED_VDS_VM_CPU_LEVEL(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_VDS_VM_NETWORKS(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_MISSING_DISPLAY_NETWORK(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_NO_VDS_AVAILABLE_IN_CLUSTER(ErrorType.CONFLICT),
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 70b8a68..13606d0 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -189,6 +189,7 @@
 ACTION_TYPE_FAILED_VDS_VM_CLUSTER=Cannot ${action} ${type}. There are no 
available running Hosts in the Host Cluster.
 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_CPU_LEVEL=Cannot ${action} ${type}. The host has 
lower CPU level than the VM was run with.
 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}.
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 f91df44..e4609f8 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
@@ -508,6 +508,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. There are no available 
running Hosts with enough cores in VM's Cluster .")
     String ACTION_TYPE_FAILED_VDS_VM_CPUS();
 
+    @DefaultStringValue("Cannot ${action} ${type}. The host has lower CPU 
level than the VM was run with.")
+    String ACTION_TYPE_FAILED_VDS_VM_CPU_LEVEL();
+
     @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();
 
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 3c8b59d..1301048 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
@@ -185,6 +185,7 @@
 ACTION_TYPE_FAILED_VDS_VM_CLUSTER=Cannot ${action} ${type}. There are no 
available running Hosts in the Host Cluster.
 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_CPU_LEVEL=Cannot ${action} ${type}. The host has 
lower CPU level than the VM was run with.
 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}.
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 1cb6615..8359df3 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
@@ -187,6 +187,7 @@
 ACTION_TYPE_FAILED_VDS_VM_CLUSTER=Cannot ${action} ${type}. There are no 
available running Hosts in the Host Cluster.
 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_CPU_LEVEL=Cannot ${action} ${type}. The host has 
lower CPU level than the VM was run with.
 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}.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib42b803fe0d2e9389d10196cd44c3fd21342927f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Oved Ourfali <oourf...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to