Eldan Shachar has uploaded a new change for review.

Change subject: core: Cluster parameters override - scheduler \ actions \ 
queries
......................................................................

core: Cluster parameters override - scheduler \ actions \ queries

This feature allows to configure the 'emulated machine' and 'cpu model' 
parameters for each VM separately instead of relying on the cluster default.

Bug-Url: https://bugzilla.redhat.com/838487
Feature-page: http://www.ovirt.org/Features/Cluster_parameters_override
Change-Id: Iea8117d8416c74b381aa8475c3fc8b02a344dbfb
Signed-off-by: Eldan Shachar <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CpuFlagsManagerHandler.java
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetSupportedCpuListQuery.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/EmulatedMachineFilterPolicyUnit.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetSupportedCpuListParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilderBase.java
A 
packaging/dbscripts/upgrade/03_06_0340_add_cluster_parameters_override_policy_unit.sql
14 files changed, 276 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/48/32548/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CpuFlagsManagerHandler.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CpuFlagsManagerHandler.java
index 8f7b924..22c9c38 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CpuFlagsManagerHandler.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CpuFlagsManagerHandler.java
@@ -42,6 +42,14 @@
         return null;
     }
 
+    public static String GetCpuNameByVDSVerbData(String name, Version ver) {
+        final CpuFlagsManager cpuFlagsManager = _managersDictionary.get(ver);
+        if (cpuFlagsManager != null) {
+            return cpuFlagsManager.GetCpuNameByVDSVerbData(name);
+        }
+        return null;
+    }
+
     public static ArchitectureType getArchitectureByCpuName(String name, 
Version ver) {
         final CpuFlagsManager cpuFlagsManager = _managersDictionary.get(ver);
         if (cpuFlagsManager != null) {
@@ -105,7 +113,22 @@
         return null;
     }
 
-    private static class CpuFlagsManager {
+
+    public static Version getLatestDictionaryVersion() {
+        return Collections.max(_managersDictionary.keySet());
+
+    }
+
+    public static List<ServerCpu> getSupportedServerCpuList(Version ver, 
String maxCpuName) {
+        final CpuFlagsManager cpuFlagsManager = _managersDictionary.get(ver);
+        if (cpuFlagsManager != null) {
+            return cpuFlagsManager.getSupportedServerCpuList(maxCpuName);
+        }
+        return new ArrayList<ServerCpu>();
+
+    }
+
+        private static class CpuFlagsManager {
         private List<ServerCpu> _intelCpuList;
         private List<ServerCpu> _amdCpuList;
         private List<ServerCpu> _ibmCpuList;
@@ -115,6 +138,12 @@
         private Map<String, ServerCpu> _amdCpuByNameDictionary =
                 new HashMap<String, ServerCpu>();
         private Map<String, ServerCpu> _ibmCpuByNameDictionary =
+                new HashMap<String, ServerCpu>();
+        private Map<String, ServerCpu> _intelCpuByVdsNameDictionary =
+                new HashMap<String, ServerCpu>();
+        private Map<String, ServerCpu> _amdCpuByVdsNameDictionary =
+                new HashMap<String, ServerCpu>();
+        private Map<String, ServerCpu> _ibmCpuByVdsNameDictionary =
                 new HashMap<String, ServerCpu>();
         private final String _intelFlag = "vmx";
         private final String _amdFlag = "svm";
@@ -186,10 +215,13 @@
                         ServerCpu sc = new ServerCpu(info[1], level, flgs, 
info[3], archType);
                         if (sc.getFlags().contains(_intelFlag)) {
                             _intelCpuByNameDictionary.put(sc.getCpuName(), sc);
+                            
_intelCpuByVdsNameDictionary.put(sc.getVdsVerbData(), sc);
                         } else if (sc.getFlags().contains(_amdFlag)) {
                             _amdCpuByNameDictionary.put(sc.getCpuName(), sc);
+                            
_amdCpuByVdsNameDictionary.put(sc.getVdsVerbData(), sc);
                         } else if (sc.getFlags().contains(_ibmFlag)) {
                             _ibmCpuByNameDictionary.put(sc.getCpuName(), sc);
+                            
_ibmCpuByVdsNameDictionary.put(sc.getVdsVerbData(), sc);
                         }
 
                         _allCpuList.add(sc);
@@ -224,6 +256,19 @@
                         || (sc = _amdCpuByNameDictionary.get(name)) != null
                         || (sc = _ibmCpuByNameDictionary.get(name)) != null) {
                     result = sc.getVdsVerbData();
+                }
+            }
+            return result;
+        }
+
+        public String GetCpuNameByVDSVerbData(String vdsName) {
+            String result = null;
+            ServerCpu sc = null;
+            if (vdsName != null) {
+                if ((sc = _intelCpuByVdsNameDictionary.get(vdsName)) != null
+                        || (sc = _amdCpuByVdsNameDictionary.get(vdsName)) != 
null
+                        || (sc = _ibmCpuByVdsNameDictionary.get(vdsName)) != 
null) {
+                    result = sc.getCpuName();
                 }
             }
             return result;
@@ -346,6 +391,40 @@
             return result;
         }
 
+
+
+
+        /**
+         * Returns a list with all CPU's which are with a lower CPU level than 
the given CPU.
+         *
+         * @param maxCpuName
+         * @return list of supported CPUs.
+         */
+        public List<ServerCpu> getSupportedServerCpuList(String maxCpuName) {
+
+            List<ServerCpu> supportedCpus = new ArrayList<ServerCpu>();
+            if (_intelCpuByNameDictionary.containsKey(maxCpuName)) {
+                ServerCpu selected = _intelCpuByNameDictionary.get(maxCpuName);
+                int selectedCpuIndex = _intelCpuList.indexOf(selected);
+                for (int i = 0; i <= selectedCpuIndex; i++) { // list is 
sorted by level
+                    supportedCpus.add(_intelCpuList.get(i));
+                }
+            } else if (_ibmCpuByNameDictionary.containsKey(maxCpuName)) {
+                    ServerCpu selected = 
_ibmCpuByNameDictionary.get(maxCpuName);
+                    int selectedCpuIndex =_ibmCpuList.indexOf(selected);
+                    for (int i = 0; i <= selectedCpuIndex; i++) {
+                        supportedCpus.add(_ibmCpuList.get(i));
+                    }
+            } else if (_amdCpuByNameDictionary.containsKey(maxCpuName)) {
+                ServerCpu selected = _amdCpuByNameDictionary.get(maxCpuName);
+                int selectedCpuIndex =_amdCpuList.indexOf(selected);
+                for (int i = 0; i <= selectedCpuIndex; i++) {
+                    supportedCpus.add(_amdCpuList.get(i));
+                }
+            }
+            return supportedCpus;
+
+        }
     }
 
     public static int compareCpuLevels(String cpuName1, String cpuName2, 
Version ver) {
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetSupportedCpuListQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetSupportedCpuListQuery.java
new file mode 100644
index 0000000..67697ca
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetSupportedCpuListQuery.java
@@ -0,0 +1,14 @@
+package org.ovirt.engine.core.bll;
+
+import org.ovirt.engine.core.common.queries.GetSupportedCpuListParameters;
+
+public class GetSupportedCpuListQuery<P extends GetSupportedCpuListParameters> 
extends QueriesCommandBase<P> {
+    public GetSupportedCpuListQuery(P parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected void executeQueryCommand() {
+        
getQueryReturnValue().setReturnValue(CpuFlagsManagerHandler.getSupportedServerCpuList(CpuFlagsManagerHandler.getLatestDictionaryVersion(),
 getParameters().getMaxCpuName()));
+    }
+}
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
index 6194d05..a030dc5 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
@@ -687,7 +687,13 @@
 
         VmHandler.updateVmGuestAgentVersion(getVm());
 
-        getVm().setCpuName(getVdsGroup().getcpu_name());
+        // update dynamic cluster-parameters
+        if(getVm().getCpuName() == null) { // no run-once data -> use static 
field or inherit from cluster
+            getVm().setCpuName((getVm().getCustomCpuName() != null ? 
getVm().getCustomCpuName() : getVm().getVdsGroupCpuFlagsData()));
+        }
+        if(getVm().getEmulatedMachine() == null) {
+            getVm().setEmulatedMachine((getVm().getCustomEmulatedMachine() != 
null ? getVm().getCustomEmulatedMachine() : 
getVdsGroup().getEmulatedMachine()));
+        }
 
         if (getFlow() != RunVmFlow.RESUME_HIBERNATE) {
             getVm().setHibernationVolHandle(getMemoryFromSnapshot());
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java
index b33035f..9e9e32b 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java
@@ -56,6 +56,9 @@
 
     @Override
     protected boolean canDoAction() {
+        /* if run-once was used then the dynamic vm fields must be updated 
before running the scheduler filters (which are called via 
super.CanDoAction->runVmValidator) */
+        earlyUpdateVmDynamicRunOnce();
+
         if (!super.canDoAction()) {
             return false;
         }
@@ -83,6 +86,23 @@
         return true;
     }
 
+    /**
+     * The function updates the dynamic vm fields with the run-once parameters 
for fields which are accessed during
+     * the validation process and thus must be updated at an earlier stage 
than the initVm() stage.
+     */
+    private void earlyUpdateVmDynamicRunOnce() {
+        if(getVm() != null) { // function is called before 
super.canDoAction(), vm object is not safe yet
+            if (getParameters().getCustomCpuName() != null) {
+                getVm().setCpuName(getParameters().getCustomCpuName());
+            }
+
+            if (getParameters().getCustomEmulatedMachine() != null) {
+                
getVm().setEmulatedMachine(getParameters().getCustomEmulatedMachine());
+            }
+        }
+
+    }
+
     private void loadPayload() {
         VmDeviceDAO dao = getDbFacade().getVmDeviceDao();
         List<VmDevice> disks = 
dao.getVmDeviceByVmIdAndType(getParameters().getVmId(), 
VmDeviceGeneralType.DISK);
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 aa827df..7d907e9 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
@@ -7,6 +7,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.EmulatedMachineFilterPolicyUnit;
 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.EvenGuestDistributionBalancePolicyUnit;
@@ -105,6 +106,8 @@
             } else if (policyUnit.getPolicyUnitType() == 
PolicyUnitType.WEIGHT) {
                 return new VmAffinityWeightPolicyUnit(policyUnit);
             }
+            case "Emulated-Machine":
+                return new EmulatedMachineFilterPolicyUnit(policyUnit);
         default:
             break;
         }
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
index aaa9d2d..b46f997 100644
--- 
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
@@ -9,6 +9,7 @@
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.scheduling.PerHostMessages;
 import org.ovirt.engine.core.common.scheduling.PolicyUnit;
+import org.ovirt.engine.core.compat.Version;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -22,35 +23,48 @@
     @Override
     public List<VDS> filter(List<VDS> hosts, VM vm, Map<String, String> 
parameters,
                             PerHostMessages messages) {
-        boolean filteredOutHosts = false;
-        if (StringUtils.isNotEmpty(vm.getCpuName())) {
-            List<VDS> hostsToRunOn = new ArrayList<VDS>();
+        List<VDS> hostsToRunOn = new ArrayList<VDS>();
+        String customCpu; // full name of the vm cpu
+        Version latestVer = 
CpuFlagsManagerHandler.getLatestDictionaryVersion();
+
+        /* get required cpu name */
+        if (StringUtils.isNotEmpty(vm.getCpuName())) { // dynamic check - used 
for 1.migrating vms 2.run-once 3.after dynamic field is updated with current 
static-field\cluster
+            customCpu = vm.getCpuName();
+        } else if (StringUtils.isNotEmpty(vm.getCustomCpuName())) { // static 
check - used only for cases where the dynamic value hasn't been updated 
yet(canDo validation)
+            customCpu = vm.getCustomCpuName();
+        } else { // use cluster default - all hosts are valid
+            return hosts;
+        }
+
+        customCpu = CpuFlagsManagerHandler.GetCpuNameByVDSVerbData(customCpu, 
latestVer); // translate vdsVerb to full cpu name
+        if(StringUtils.isNotEmpty(customCpu)) { // checks if there's a cpu 
with the given vdsVerb
+
+            /* find compatible hosts */
             for (VDS host : hosts) {
-                ServerCpu cpu = 
CpuFlagsManagerHandler.FindMaxServerCpuByFlags(host.getCpuFlags(), 
host.getVdsGroupCompatibilityVersion());
+                ServerCpu cpu = 
CpuFlagsManagerHandler.FindMaxServerCpuByFlags(host.getCpuFlags(), latestVer);
                 String hostCpuName = cpu == null ? null : cpu.getCpuName();
                 if (StringUtils.isNotEmpty(hostCpuName)) {
-                    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());
-                        messages.addMessage(host.getId(), 
String.format("$hostCPULevel %1$s", hostCpuName));
-                        messages.addMessage(host.getId(), 
String.format("$vmCPULevel %1$s", vm.getCpuName()));
-                        messages.addMessage(host.getId(), 
VdcBllMessages.VAR__DETAIL__LOW_CPU_LEVEL.toString());
+                    if 
(CpuFlagsManagerHandler.CheckIfCpusSameManufacture(customCpu, hostCpuName, 
latestVer)) { // verify comparison uses only one cpu-level scale
+                        int compareResult = 
CpuFlagsManagerHandler.compareCpuLevels(customCpu, hostCpuName, latestVer);
+                        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,
+                                    customCpu);
+                        } 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,
+                                    customCpu);
+                            messages.addMessage(host.getId(), 
String.format("$hostCPULevel %1$s", hostCpuName));
+                            messages.addMessage(host.getId(), 
String.format("$vmCPULevel %1$s", customCpu));
+                            messages.addMessage(host.getId(), 
VdcBllMessages.VAR__DETAIL__LOW_CPU_LEVEL.toString());
+                        }
                     }
                 }
             }
-
-            return hostsToRunOn;
-        } else {
-            return hosts;
         }
+        return hostsToRunOn;
     }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/EmulatedMachineFilterPolicyUnit.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/EmulatedMachineFilterPolicyUnit.java
new file mode 100644
index 0000000..9252657
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/EmulatedMachineFilterPolicyUnit.java
@@ -0,0 +1,56 @@
+package org.ovirt.engine.core.bll.scheduling.policyunits;
+
+import org.apache.commons.lang.StringUtils;
+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.PerHostMessages;
+import org.ovirt.engine.core.common.scheduling.PolicyUnit;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+public class EmulatedMachineFilterPolicyUnit extends PolicyUnitImpl {
+    public EmulatedMachineFilterPolicyUnit(PolicyUnit policyUnit) {
+        super(policyUnit);
+    }
+
+    @Override
+    public List<VDS> filter(List<VDS> hosts, VM vm, Map<String, String> 
parameters,
+                            PerHostMessages messages) {
+        String requiredEmulatedMachine;
+        List<VDS> hostsToRunOn = new ArrayList<VDS>();
+
+        /* get required emulated machine */
+        if (StringUtils.isNotEmpty(vm.getEmulatedMachine())) { // dynamic 
check - used for 1.migrating vms 2.run-once 3.after dynamic field is updated 
with current static-field\cluster
+            requiredEmulatedMachine = vm.getEmulatedMachine();
+        } else if (StringUtils.isNotEmpty(vm.getCustomEmulatedMachine())) { // 
static check - used only for cases where the dynamic value hasn't been updated 
yet(canDo validation)
+            requiredEmulatedMachine = vm.getCustomEmulatedMachine();
+        } else { // use cluster default - all hosts are valid
+            return hosts;
+        }
+
+        /* find compatible hosts */
+        for (VDS host : hosts) {
+            String supportedEmulatedMachines = 
host.getSupportedEmulatedMachines();
+            if(StringUtils.isNotEmpty(supportedEmulatedMachines)) {
+                if 
(Arrays.asList(supportedEmulatedMachines.split(",")).contains(requiredEmulatedMachine))
 {
+                    hostsToRunOn.add(host);
+                    log.debugFormat("Host {0} wasn't filtered out as it 
supports the VM required emulated machine ({1})",
+                            host.getName(),
+                            requiredEmulatedMachine);
+                } else {
+                    log.debugFormat("Host {0} was filtered out as it doesn't 
support the VM required emulated machine ({1})",
+                            host.getName(),
+                            requiredEmulatedMachine);
+                    messages.addMessage(host.getId(), 
String.format("$vmEmulatedMachine %1$s", requiredEmulatedMachine));
+                    messages.addMessage(host.getId(), 
VdcBllMessages.VAR__DETAIL__UNSUPPORTED_EMULATED_MACHINE.toString());
+                }
+            }
+        }
+        return hostsToRunOn;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
index a647801..de086d2 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
@@ -16,6 +16,9 @@
     private VmInit vmInit;
     private Guid destinationVdsId;
 
+    private String customEmulatedMachine;
+    private String customCpuName;
+
     @NullOrStringContainedInConfigValueList(configValue = 
ConfigValues.VncKeyboardLayoutValidValues,
             groups = { StartEntity.class }, message = 
"VALIDATION.VM.INVALID_KEYBOARD_LAYOUT")
     private String vncKeyboardLayout;
@@ -75,4 +78,21 @@
     public void setDestinationVdsId(Guid destinationVdsId) {
         this.destinationVdsId = destinationVdsId;
     }
+
+    public String getCustomEmulatedMachine() {
+        return customEmulatedMachine;
+    }
+
+    public void setCustomEmulatedMachine(String customEmulatedMachine) {
+        this.customEmulatedMachine = ((customEmulatedMachine == null || 
customEmulatedMachine.length() == 0) ? null : customEmulatedMachine);
+    }
+
+    public String getCustomCpuName() {
+        return customCpuName;
+    }
+
+    public void setCustomCpuName(String customCpuName) {
+        this.customCpuName = ((customCpuName == null || customCpuName.length() 
== 0) ? null : customCpuName);
+    }
+
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
index a54334b..24377cf 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
@@ -215,4 +215,5 @@
     public void setSpiceCopyPasteEnabled(Boolean spiceCopyPasteEnabled) {
         this.spiceCopyPasteEnabled = spiceCopyPasteEnabled;
     }
+
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetSupportedCpuListParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetSupportedCpuListParameters.java
new file mode 100644
index 0000000..110acfc
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetSupportedCpuListParameters.java
@@ -0,0 +1,19 @@
+package org.ovirt.engine.core.common.queries;
+
+public class GetSupportedCpuListParameters extends VdcQueryParametersBase {
+
+    private static final long serialVersionUID = -6961495931946670043L;
+
+    public GetSupportedCpuListParameters(String maxCpuName) {
+        _maxCpuName = maxCpuName;
+    }
+
+    private String _maxCpuName;
+
+    public String getMaxCpuName() {
+        return _maxCpuName;
+    }
+
+    public GetSupportedCpuListParameters() {
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
index 7ac717d..dc8b41c 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
@@ -220,6 +220,7 @@
 
     // License queries
     GetAllServerCpuList,
+    GetSupportedCpuList(VdcQueryAuthType.User),
 
     // Multi Level Administration queries
     GetAllRoles(VdcQueryAuthType.User),
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
index 0d2f296..7654766 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java
@@ -332,6 +332,7 @@
         vm.setVmIp(null);
         vm.setVmFQDN(null);
         vm.setCpuName(null);
+        vm.setEmulatedMachine(null);
         vm.setMigrationProgressPercent(0);
         List<VmNetworkInterface> interfaces = vm.getInterfaces();
         for (VmNetworkInterface ifc : interfaces) {
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilderBase.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilderBase.java
index 54b9e65..87f1dc1 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilderBase.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilderBase.java
@@ -90,7 +90,9 @@
         }
         final String compatibilityVersion = 
vm.getVdsGroupCompatibilityVersion().toString();
         addCpuPinning(compatibilityVersion);
-        createInfo.put(VdsProperties.emulatedMachine, 
getVdsGroup().getEmulatedMachine());
+        if(vm.getEmulatedMachine() != null) {
+            createInfo.put(VdsProperties.emulatedMachine, 
vm.getEmulatedMachine());
+        }
         // send cipher suite and spice secure channels parameters only if ssl
         // enabled.
         if (Config.<Boolean> getValue(ConfigValues.SSLEnabled)) {
@@ -115,9 +117,8 @@
         if (vm.isUseHostCpuFlags()) {
             createInfo.put(VdsProperties.cpuType,
                     "hostPassthrough");
-        } else if (vm.getVdsGroupCpuFlagsData() != null) {
-            createInfo.put(VdsProperties.cpuType,
-                    vm.getVdsGroupCpuFlagsData());
+        } else if (vm.getCpuName() != null) { // uses dynamic vm data which 
was already updated by runVmCommand
+            createInfo.put(VdsProperties.cpuType, vm.getCpuName());
         }
         createInfo.put(VdsProperties.niceLevel,
                 String.valueOf(vm.getNiceLevel()));
diff --git 
a/packaging/dbscripts/upgrade/03_06_0340_add_cluster_parameters_override_policy_unit.sql
 
b/packaging/dbscripts/upgrade/03_06_0340_add_cluster_parameters_override_policy_unit.sql
new file mode 100644
index 0000000..9fe85f9
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_06_0340_add_cluster_parameters_override_policy_unit.sql
@@ -0,0 +1,12 @@
+CREATE FUNCTION _createFilter(uuid, character varying(128), text) RETURNS void 
AS $$
+  INSERT INTO policy_units (id, name, is_internal, custom_properties_regex, 
type, enabled, description) VALUES ($1, $2, true, NULL, 0, true, $3);
+  INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('20d25257-b4bd-4589-92a6-c4c5c5d3fd1a', $1, 0, 
0);
+  INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('5a2b0939-7d46-4b73-a469-e9c2c7fc6a53', $1, 0, 
0);
+  INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('b4ed2332-a7ac-4d5f-9596-99a439cb2812', $1, 0, 
0);
+  INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('8d5d7bec-68de-4a67-b53e-0ac54686d579', $1, 0, 
0);
+$$ LANGUAGE SQL;
+
+
+select _createFilter(uuid_generate_v1(), 'Emulated-Machine', 'Runs VMs only on 
hosts with a proper emulated machine support');
+
+DROP FUNCTION  _createFilter(uuid, character varying(128), text);
\ No newline at end of file


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

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

Reply via email to