Oved Ourfali has uploaded a new change for review.

Change subject: core: adding HA score with proper scheduling policies
......................................................................

core: adding HA score with proper scheduling policies

This patch adds the HA score to VdsDynamic, filling it up where
relevant, and using it when scheduling the hosted engine VM.

Change-Id: I24879ed64cab829969556fd71786b32d3aaaf0c7
Signed-off-by: Oved Ourfali <oourf...@redhat.com>
---
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/HAClusterFilterPolicyUnit.java
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HAClusterWeightPolicyUnit.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
M packaging/dbscripts/create_views.sql
A packaging/dbscripts/upgrade/03_03_0980_add_ha_score_to_vds_dynamic.sql
A packaging/dbscripts/upgrade/03_03_0990_add_ha_policy_units.sql
M packaging/dbscripts/vds_sp.sql
15 files changed, 144 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/20018/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 76df24b..090ffb6 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
@@ -9,6 +9,8 @@
 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.HAClusterFilterPolicyUnit;
+import 
org.ovirt.engine.core.bll.scheduling.policyunits.HAClusterWeightPolicyUnit;
 import org.ovirt.engine.core.bll.scheduling.policyunits.MemoryPolicyUnit;
 import org.ovirt.engine.core.bll.scheduling.policyunits.NetworkPolicyUnit;
 import org.ovirt.engine.core.bll.scheduling.policyunits.NoneBalancePolicyUnit;
@@ -41,6 +43,12 @@
             return new MemoryPolicyUnit(policyUnit);
         case "Network":
             return new NetworkPolicyUnit(policyUnit);
+        case "HA":
+            if (policyUnit.getPolicyUnitType() == PolicyUnitType.Weight) {
+                return new HAClusterWeightPolicyUnit(policyUnit);
+            } else if (policyUnit.getPolicyUnitType() == 
PolicyUnitType.Filter) {
+                return new HAClusterFilterPolicyUnit(policyUnit);
+            }
         case "CPU-Level":
             return new CpuLevelFilterPolicyUnit(policyUnit);
         case "None":
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HAClusterFilterPolicyUnit.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HAClusterFilterPolicyUnit.java
new file mode 100644
index 0000000..8c2aa7f
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HAClusterFilterPolicyUnit.java
@@ -0,0 +1,39 @@
+package org.ovirt.engine.core.bll.scheduling.policyunits;
+
+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.scheduling.PolicyUnit;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HAClusterFilterPolicyUnit extends PolicyUnitImpl {
+    public HAClusterFilterPolicyUnit(PolicyUnit policyUnit) {
+        super(policyUnit);
+    }
+
+    @Override
+    public List<VDS> filter(List<VDS> hosts, VM vm, Map<String, String> 
parameters, List<String> messages) {
+
+        // The filter is relevant only for Hosted Engine VM
+        if (vm.isHostedEngine()) {
+            List<VDS> hostsToRunOn = new ArrayList<VDS>();
+            for (VDS host : hosts) {
+                if (host.getDynamicData().getHighlyAvailableScore() != 0 ) {
+                    hostsToRunOn.add(host);
+                    log.debugFormat("Host {0} wasn't filtered out as it has a 
score of {1}",
+                            host.getName(),
+                            host.getDynamicData().getHighlyAvailableScore());
+                } else {
+                    log.debugFormat("Host {0} was filtered out as it doesn't 
have a positive score", host.getName());
+                }
+            }
+
+            return hostsToRunOn;
+        } else {
+            return hosts;
+        }
+    }
+}
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HAClusterWeightPolicyUnit.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HAClusterWeightPolicyUnit.java
new file mode 100644
index 0000000..738a889
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/HAClusterWeightPolicyUnit.java
@@ -0,0 +1,36 @@
+package org.ovirt.engine.core.bll.scheduling.policyunits;
+
+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.scheduling.PolicyUnit;
+import org.ovirt.engine.core.common.utils.Pair;
+import org.ovirt.engine.core.compat.Guid;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HAClusterWeightPolicyUnit extends PolicyUnitImpl {
+    private static int DEFAULT_SCORE = 1;
+
+    public HAClusterWeightPolicyUnit(PolicyUnit policyUnit) {
+        super(policyUnit);
+    }
+
+    Integer calcNormalizedHaScore(VDS vds) {
+        return MaxSchedulerWeight - 
vds.getDynamicData().getHighlyAvailableScore();
+    }
+
+    @Override
+    public List<Pair<Guid, Integer>> score(List<VDS> hosts, VM vm, Map<String, 
String> parameters) {
+        List<Pair<Guid, Integer>> scores = new ArrayList<Pair<Guid, 
Integer>>();
+        boolean isHostedEngine = vm.isHostedEngine();
+
+        for (VDS vds : hosts) {
+            scores.add(new Pair<Guid, Integer>(vds.getId(), isHostedEngine ? 
calcNormalizedHaScore(vds) : DEFAULT_SCORE));
+        }
+        return scores;
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
index dd2baee..060cc4d 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
@@ -556,6 +556,14 @@
         this.mVdsDynamic.setvm_active(value);
     }
 
+    public int getHighlyAvailableScore() {
+        return this.mVdsDynamic.getHighlyAvailableScore();
+    }
+
+    public void setHighlyAvailableScore(int value) {
+        this.mVdsDynamic.setHighlyAvailableScore(value);
+    }
+
     public int getVmCount() {
         return this.mVdsDynamic.getvm_count();
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
index 5275592..50f16ab 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
@@ -85,6 +85,8 @@
 
     private VdsTransparentHugePagesState transparentHugePagesState;
 
+    private int highlyAvailableScore;
+
     @Size(max = BusinessEntitiesDefinitions.GENERAL_NAME_SIZE)
     private Map<String, List<Map<String, String>>> HBAs; /* Store the list of 
HBAs */
 
@@ -164,6 +166,7 @@
         vm_count = 0;
         vms_cores_count = 0;
         guest_overhead = 0;
+        highlyAvailableScore = 0;
     }
 
     public Integer getcpu_cores() {
@@ -562,6 +565,14 @@
         this.nonOperationalReason = (nonOperationalReason == null ? 
NonOperationalReason.NONE : nonOperationalReason);
     }
 
+    public int getHighlyAvailableScore() {
+        return highlyAvailableScore;
+    }
+
+    public void setHighlyAvailableScore(int value) {
+        highlyAvailableScore = value;
+    }
+
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -614,6 +625,7 @@
         result = prime * result + ((hwUUID == null) ? 0 : hwUUID.hashCode());
         result = prime * result + ((hwFamily == null) ? 0 : 
hwFamily.hashCode());
         result = prime * result + ((HBAs == null) ? 0 : HBAs.hashCode());
+        result = prime * result + highlyAvailableScore;
         return result;
     }
 
@@ -677,7 +689,8 @@
                 && ObjectUtils.objectsEqual(hwUUID, other.hwUUID)
                 && ObjectUtils.objectsEqual(hwFamily, other.hwFamily)
                 && ObjectUtils.objectsEqual(HBAs, other.HBAs)
-                && ObjectUtils.objectsEqual(supportedEmulatedMachines, 
other.supportedEmulatedMachines));
+                && ObjectUtils.objectsEqual(supportedEmulatedMachines, 
other.supportedEmulatedMachines)
+                && highlyAvailableScore == other.highlyAvailableScore);
     }
 
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
index 2b09bfb..e5d1662 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
@@ -337,6 +337,7 @@
             entity.setHBAs(new 
JsonObjectDeserializer().deserialize(rs.getString("hbas"), HashMap.class));
             entity.setConsoleAddress(rs.getString("console_address"));
             
entity.setSupportedEmulatedMachines(rs.getString("supported_emulated_machines"));
+            entity.setHighlyAvailableScore(rs.getInt("ha_score"));
             entity.calculateFreeVirtualMemory();
             return entity;
         }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
index bda9460..99bd04c 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
@@ -152,7 +152,8 @@
                 .addValue("hw_uuid", vds.getHardwareUUID())
                 .addValue("hw_family", vds.getHardwareFamily())
                 .addValue("hbas", new 
JsonObjectSerializer().serialize(vds.getHBAs()))
-                .addValue("supported_emulated_machines", 
vds.getSupportedEmulatedMachines());
+                .addValue("supported_emulated_machines", 
vds.getSupportedEmulatedMachines())
+                .addValue("ha_score", vds.getHighlyAvailableScore());
 
         getCallsHandler().executeModification("InsertVdsDynamic", 
parameterSource);
     }
@@ -210,7 +211,8 @@
                 .addValue("hw_uuid", vds.getHardwareUUID())
                 .addValue("hw_family", vds.getHardwareFamily())
                 .addValue("hbas", new 
JsonObjectSerializer().serialize(vds.getHBAs()))
-                .addValue("supported_emulated_machines", 
vds.getSupportedEmulatedMachines());
+                .addValue("supported_emulated_machines", 
vds.getSupportedEmulatedMachines())
+                .addValue("ha_score", vds.getHighlyAvailableScore());
 
         getCallsHandler().executeModification("UpdateVdsDynamic", 
parameterSource);
     }
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index a24b2d9..627b5ae 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -2055,6 +2055,7 @@
         <column>hw_uuid</column>
         <column>hw_family</column>
         <column>supported_emulated_machines</column>
+        <column>ha_score</column>
         <row>
             <value>afce7a39-8e8c-4819-ba9c-796d316592e6</value>
             <value>3</value>
@@ -2102,6 +2103,7 @@
             <null />
             <null />
             <null />
+            <value>0</value>
         </row>
         <row>
             <value>afce7a39-8e8c-4819-ba9c-796d316592e7</value>
@@ -2150,6 +2152,7 @@
             <null />
             <null />
             <value>rhel6.4,rhel6.4,pc-1.1,pc-1.0</value>
+            <value>0</value>
         </row>
         <row>
             <value>afce7a39-8e8c-4819-ba9c-796d316592e8</value>
@@ -2198,6 +2201,7 @@
             <null />
             <null />
             <value>rhel6.4,rhel6.4,pc-1.1,pc-1.0</value>
+            <value>0</value>
         </row>
         <row>
             <value>23f6d691-5dfb-472b-86dc-9e1d2d3c18f3</value>
@@ -2246,6 +2250,7 @@
             <null />
             <null />
             <value>rhel6.4,rhel6.4,pc-1.1,pc-1.0</value>
+            <value>0</value>
         </row>
         <row>
             <value>2001751e-549b-4e7a-aff6-32d36856c125</value>
@@ -2294,6 +2299,7 @@
             <null />
             <null />
             <value>rhel6.4,rhel6.4,pc-1.1,pc-1.0</value>
+            <value>0</value>
         </row>
     </table>
 
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
index 2b64237..62efa31 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
@@ -21,6 +21,7 @@
 import org.ovirt.engine.core.common.businessentities.DiskImage;
 import org.ovirt.engine.core.common.businessentities.DiskImageDynamic;
 import org.ovirt.engine.core.common.businessentities.Entities;
+import org.ovirt.engine.core.common.businessentities.MigrationSupport;
 import org.ovirt.engine.core.common.businessentities.OriginType;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
@@ -1567,6 +1568,7 @@
                 if (StringUtils.equals(HOSTED_ENGINE_VM_NAME, vmNameOnHost)) {
                     vmStatic.setName(vmNameOnHost);
                     vmStatic.setOrigin(OriginType.HOSTED_ENGINE);
+                    
vmStatic.setMigrationSupport(MigrationSupport.IMPLICITLY_NON_MIGRATABLE);
                 } else {
                     vmStatic.setName(String.format(EXTERNAL_VM_NAME_FORMAT, 
vmNameOnHost));
                     vmStatic.setOrigin(OriginType.EXTERNAL);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
index e1e6ae5..48b9210 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
@@ -339,6 +339,8 @@
         vds.setGuestOverhead(guestOverhead != null ? guestOverhead : 0);
 
         vds.setCpuFlags(AssignStringValue(xmlRpcStruct, 
VdsProperties.cpu_flags));
+        Integer haScore = AssignIntValue(xmlRpcStruct, VdsProperties.ha_score);
+        vds.setHighlyAvailableScore(haScore != null ? haScore : 0);
 
         UpdatePackagesVersions(vds, xmlRpcStruct);
 
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
index de688ac..cde4081 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
@@ -66,6 +66,7 @@
     public static final String vm_migrating = "vmMigrating";
     public static final String images_last_check = "imagesLastCheck";
     public static final String images_last_delay = "imagesLastDelay";
+    public static final String ha_score = "haScore";
 
     public static final String INTERFACE = "iface";
 
diff --git a/packaging/dbscripts/create_views.sql 
b/packaging/dbscripts/create_views.sql
index b3893b4..a426c82 100644
--- a/packaging/dbscripts/create_views.sql
+++ b/packaging/dbscripts/create_views.sql
@@ -668,7 +668,7 @@
                       vds_dynamic.transparent_hugepages_state as 
transparent_hugepages_state, vds_dynamic.anonymous_hugepages as 
anonymous_hugepages, vds_dynamic.non_operational_reason as 
non_operational_reason,
                        vds_static.recoverable as recoverable, 
vds_static.sshKeyFingerprint as sshKeyFingerprint, vds_dynamic.hw_manufacturer 
as hw_manufacturer, vds_dynamic.hw_product_name as hw_product_name, 
vds_dynamic.hw_version as hw_version,
                       vds_dynamic.hw_serial_number as hw_serial_number, 
vds_dynamic.hw_uuid as hw_uuid, vds_dynamic.hw_family as hw_family, 
vds_static.console_address as console_address,
-                      vds_dynamic.hbas as hbas, 
vds_dynamic.supported_emulated_machines as supported_emulated_machines, 
vds_static.ssh_port as ssh_port, vds_static.ssh_username as ssh_username
+                      vds_dynamic.hbas as hbas, 
vds_dynamic.supported_emulated_machines as supported_emulated_machines, 
vds_static.ssh_port as ssh_port, vds_static.ssh_username as ssh_username, 
vds_dynamic.ha_score as ha_score
 FROM         vds_groups INNER JOIN
 vds_static ON vds_groups.vds_group_id = vds_static.vds_group_id INNER JOIN
 vds_dynamic ON vds_static.vds_id = vds_dynamic.vds_id INNER JOIN
@@ -709,7 +709,7 @@
                       vds_groups.compatibility_version AS 
vds_group_compatibility_version, vds_dynamic.host_os, vds_dynamic.kvm_version, 
vds_dynamic.libvirt_version,
                       vds_dynamic.spice_version, vds_dynamic.kernel_version, 
vds_dynamic.iscsi_initiator_name,
                       vds_dynamic.transparent_hugepages_state, 
vds_dynamic.anonymous_hugepages, vds_dynamic.non_operational_reason,
-                      storage_pool_iso_map.storage_id, vds_static.ssh_port, 
vds_static.ssh_username
+                      storage_pool_iso_map.storage_id, vds_static.ssh_port, 
vds_static.ssh_username, vds_dynamic.ha_score as ha_score
 FROM         vds_groups INNER JOIN
 vds_static ON vds_groups.vds_group_id = vds_static.vds_group_id INNER JOIN
 vds_dynamic ON vds_static.vds_id = vds_dynamic.vds_id INNER JOIN
diff --git 
a/packaging/dbscripts/upgrade/03_03_0980_add_ha_score_to_vds_dynamic.sql 
b/packaging/dbscripts/upgrade/03_03_0980_add_ha_score_to_vds_dynamic.sql
new file mode 100644
index 0000000..66a8206
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_03_0980_add_ha_score_to_vds_dynamic.sql
@@ -0,0 +1,3 @@
+
+select fn_db_add_column('vds_dynamic', 'ha_score', 'INTEGER NOT NULL DEFAULT 
0');
+
diff --git a/packaging/dbscripts/upgrade/03_03_0990_add_ha_policy_units.sql 
b/packaging/dbscripts/upgrade/03_03_0990_add_ha_policy_units.sql
new file mode 100644
index 0000000..8361cf7
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_03_0990_add_ha_policy_units.sql
@@ -0,0 +1,11 @@
+
+INSERT INTO policy_units (id, name, is_internal, custom_properties_regex, 
type, enabled, description) VALUES ('e659c871-0bf1-4ccc-b748-f28f5d08dffd', 
'HA', true, NULL, 0, true, 'Runs the hosted engine VM only on hosts with a 
positive score');
+INSERT INTO policy_units (id, name, is_internal, custom_properties_regex, 
type, enabled, description) VALUES ('98e92667-6161-41fb-b3fa-34f820ccbc4b', 
'HA', true, NULL, 1, true, 'Weights hosts according to there HA score');
+
+INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('20d25257-b4bd-4589-92a6-c4c5c5d3fd1a', 
'e659c871-0bf1-4ccc-b748-f28f5d08dffd', 0, 0);
+INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('5a2b0939-7d46-4b73-a469-e9c2c7fc6a53', 
'e659c871-0bf1-4ccc-b748-f28f5d08dffd', 0, 0);
+INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('b4ed2332-a7ac-4d5f-9596-99a439cb2812', 
'e659c871-0bf1-4ccc-b748-f28f5d08dffd', 0, 0);
+
+INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('20d25257-b4bd-4589-92a6-c4c5c5d3fd1a', 
'98e92667-6161-41fb-b3fa-34f820ccbc4b', 0, 1);
+INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('5a2b0939-7d46-4b73-a469-e9c2c7fc6a53', 
'98e92667-6161-41fb-b3fa-34f820ccbc4b', 0, 1);
+INSERT INTO cluster_policy_units (cluster_policy_id, policy_unit_id, 
filter_sequence, factor) VALUES ('b4ed2332-a7ac-4d5f-9596-99a439cb2812', 
'98e92667-6161-41fb-b3fa-34f820ccbc4b', 0, 1);
diff --git a/packaging/dbscripts/vds_sp.sql b/packaging/dbscripts/vds_sp.sql
index 5781ce9..8d91249 100644
--- a/packaging/dbscripts/vds_sp.sql
+++ b/packaging/dbscripts/vds_sp.sql
@@ -182,14 +182,15 @@
  v_hw_uuid VARCHAR(255),
  v_hw_family VARCHAR(255),
  v_hbas VARCHAR(255),
- v_supported_emulated_machines VARCHAR(255))
+ v_supported_emulated_machines VARCHAR(255),
+ v_ha_score INTEGER)
 RETURNS VOID
    AS $procedure$
 BEGIN
 
    BEGIN
-INSERT INTO vds_dynamic(cpu_cores, cpu_threads, cpu_model, cpu_speed_mh, 
if_total_speed, kvm_enabled, mem_commited, physical_mem_mb,   status, vds_id, 
vm_active, vm_count, vm_migrating, reserved_mem, guest_overhead, rpm_version, 
software_version, version_name, build_name, previous_status, cpu_flags, 
cpu_over_commit_time_stamp, vms_cores_count, pending_vcpus_count, 
pending_vmem_size, cpu_sockets,net_config_dirty, supported_cluster_levels, 
supported_engines, host_os, kvm_version, libvirt_version, spice_version, 
kernel_version, iscsi_initiator_name, transparent_hugepages_state, 
anonymous_hugepages,hooks, hw_manufacturer, hw_product_name, hw_version, 
hw_serial_number, hw_uuid, hw_family, hbas, supported_emulated_machines)
-       VALUES(v_cpu_cores,     v_cpu_threads, v_cpu_model,     v_cpu_speed_mh, 
v_if_total_speed, v_kvm_enabled, v_mem_commited, v_physical_mem_mb,     
v_status, v_vds_id, v_vm_active, v_vm_count, v_vm_migrating,    v_reserved_mem, 
v_guest_overhead, v_rpm_version, v_software_version, v_version_name, 
v_build_name, v_previous_status, v_cpu_flags, v_cpu_over_commit_time_stamp, 
v_vms_cores_count,v_pending_vcpus_count, v_pending_vmem_size, v_cpu_sockets, 
v_net_config_dirty, v_supported_cluster_levels, v_supported_engines, v_host_os, 
v_kvm_version, v_libvirt_version, v_spice_version, v_kernel_version, 
v_iscsi_initiator_name, v_transparent_hugepages_state, 
v_anonymous_hugepages,v_hooks, v_hw_manufacturer, v_hw_product_name, 
v_hw_version, v_hw_serial_number, v_hw_uuid, v_hw_family, v_hbas, 
v_supported_emulated_machines);
+INSERT INTO vds_dynamic(cpu_cores, cpu_threads, cpu_model, cpu_speed_mh, 
if_total_speed, kvm_enabled, mem_commited, physical_mem_mb,   status, vds_id, 
vm_active, vm_count, vm_migrating, reserved_mem, guest_overhead, rpm_version, 
software_version, version_name, build_name, previous_status, cpu_flags, 
cpu_over_commit_time_stamp, vms_cores_count, pending_vcpus_count, 
pending_vmem_size, cpu_sockets,net_config_dirty, supported_cluster_levels, 
supported_engines, host_os, kvm_version, libvirt_version, spice_version, 
kernel_version, iscsi_initiator_name, transparent_hugepages_state, 
anonymous_hugepages,hooks, hw_manufacturer, hw_product_name, hw_version, 
hw_serial_number, hw_uuid, hw_family, hbas, supported_emulated_machines, 
ha_score)
+       VALUES(v_cpu_cores,     v_cpu_threads, v_cpu_model,     v_cpu_speed_mh, 
v_if_total_speed, v_kvm_enabled, v_mem_commited, v_physical_mem_mb,     
v_status, v_vds_id, v_vm_active, v_vm_count, v_vm_migrating,    v_reserved_mem, 
v_guest_overhead, v_rpm_version, v_software_version, v_version_name, 
v_build_name, v_previous_status, v_cpu_flags, v_cpu_over_commit_time_stamp, 
v_vms_cores_count,v_pending_vcpus_count, v_pending_vmem_size, v_cpu_sockets, 
v_net_config_dirty, v_supported_cluster_levels, v_supported_engines, v_host_os, 
v_kvm_version, v_libvirt_version, v_spice_version, v_kernel_version, 
v_iscsi_initiator_name, v_transparent_hugepages_state, 
v_anonymous_hugepages,v_hooks, v_hw_manufacturer, v_hw_product_name, 
v_hw_version, v_hw_serial_number, v_hw_uuid, v_hw_family, v_hbas, 
v_supported_emulated_machines, v_ha_score);
    END;
 
    RETURN;
@@ -246,7 +247,8 @@
  v_hw_uuid VARCHAR(255),
  v_hw_family VARCHAR(255),
  v_hbas VARCHAR(255),
- v_supported_emulated_machines VARCHAR(255))
+ v_supported_emulated_machines VARCHAR(255),
+ v_ha_score INTEGER)
 RETURNS VOID
 
        --The [vds_dynamic] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
@@ -276,7 +278,7 @@
       _update_date = LOCALTIMESTAMP,non_operational_reason = 
v_non_operational_reason,
       hw_manufacturer = v_hw_manufacturer, hw_product_name = v_hw_product_name,
       hw_version = v_hw_version, hw_serial_number = v_hw_serial_number,
-      hw_uuid = v_hw_uuid, hw_family = v_hw_family, hbas = v_hbas, 
supported_emulated_machines = v_supported_emulated_machines
+      hw_uuid = v_hw_uuid, hw_family = v_hw_family, hbas = v_hbas, 
supported_emulated_machines = v_supported_emulated_machines, ha_score = 
v_ha_score
       WHERE vds_id = v_vds_id;
    END;
 


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

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