Oved Ourfali has uploaded a new change for review. Change subject: core: adding a filter policy for CPU level ......................................................................
core: adding a filter policy for CPU level Change-Id: Ib42b803fe0d2e9389d10196cd44c3fd21342927f Bug-Url: https://bugzilla.redhat.com/1006209 Signed-off-by: Oved Ourfali <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java 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 A packaging/dbscripts/upgrade/03_03_0970_add_cpu_level_policy_unit.sql 8 files changed, 67 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/33/20233/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java index d11adf2..a93d8cb 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java @@ -6,6 +6,7 @@ import org.apache.commons.lang.NotImplementedException; import org.ovirt.engine.core.bll.scheduling.policyunits.CPUPolicyUnit; +import org.ovirt.engine.core.bll.scheduling.policyunits.CpuLevelFilterPolicyUnit; import org.ovirt.engine.core.bll.scheduling.policyunits.EvenDistributionBalancePolicyUnit; import org.ovirt.engine.core.bll.scheduling.policyunits.EvenDistributionWeightPolicyUnit; import org.ovirt.engine.core.bll.scheduling.policyunits.MemoryPolicyUnit; @@ -40,6 +41,8 @@ return new MemoryPolicyUnit(policyUnit); case "Network": return new NetworkPolicyUnit(policyUnit); + case "CPU-Level": + return new CpuLevelFilterPolicyUnit(policyUnit); case "None": if (policyUnit.getPolicyUnitType() == PolicyUnitType.Weight) { return new NoneWeightPolicyUnit(policyUnit); 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..b01de0d --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java @@ -0,0 +1,52 @@ +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) { + boolean filteredOutHosts = false; + if (StringUtils.isNotEmpty(vm.getCpuName())) { + List<VDS> hostsToRunOn = new ArrayList<VDS>(); + for (VDS host : hosts) { + String hostCpuName = CpuFlagsManagerHandler.FindMaxServerCpuByFlags(host.getCpuFlags(), host.getVdsGroupCompatibilityVersion()).getCpuName(); + int compareResult = CpuFlagsManagerHandler.compareCpuLevels(vm.getCpuName(), hostCpuName, vm.getVdsGroupCompatibilityVersion()); + if (compareResult <= 0) { + hostsToRunOn.add(host); + log.debugFormat("Host {0} wasn't filtered out as it has a CPU level ({1}) which is higher or equal than the CPU level the VM was run with ({2})", + host.getName(), + hostCpuName, + vm.getCpuName()); + } else { + log.debugFormat("Host {0} was filtered out as it has a CPU level ({1}) which is lower than the CPU level the VM was run with ({2})", + host.getName(), + hostCpuName, + vm.getCpuName()); + filteredOutHosts = true; + } + } + + if (filteredOutHosts) { + messages.add(VdcBllMessages.ACTION_TYPE_FAILED_VDS_VM_CPU_LEVEL.toString()); + } + + 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 a207f16..a5d6f6e 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 @@ -179,6 +179,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 75d36cf..4326536 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 085cf37..b06dc95 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 aecc0e1..d621b8c 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 5e018ec..e042e4f 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}. diff --git a/packaging/dbscripts/upgrade/03_03_0970_add_cpu_level_policy_unit.sql b/packaging/dbscripts/upgrade/03_03_0970_add_cpu_level_policy_unit.sql new file mode 100644 index 0000000..a63af9a --- /dev/null +++ b/packaging/dbscripts/upgrade/03_03_0970_add_cpu_level_policy_unit.sql @@ -0,0 +1,5 @@ + +INSERT INTO policy_units (id, name, is_internal, custom_properties_regex, type, enabled, description) VALUES ('438b052c-90ab-40e8-9be0-a22560202ea6', 'CPU-Level', true, NULL, 0, true, 'Runs VMs only on hosts with a proper CPU level'); +INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, filter_sequence, factor) VALUES ('20d25257-b4bd-4589-92a6-c4c5c5d3fd1a', '438b052c-90ab-40e8-9be0-a22560202ea6', 0, 0); +INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, filter_sequence, factor) VALUES ('5a2b0939-7d46-4b73-a469-e9c2c7fc6a53', '438b052c-90ab-40e8-9be0-a22560202ea6', 0, 0); +INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, filter_sequence, factor) VALUES ('b4ed2332-a7ac-4d5f-9596-99a439cb2812', '438b052c-90ab-40e8-9be0-a22560202ea6', 0, 0); -- To view, visit http://gerrit.ovirt.org/20233 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib42b803fe0d2e9389d10196cd44c3fd21342927f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Oved Ourfali <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
