Tomas Jelinek has uploaded a new change for review.

Change subject: core: disable the mixing of RHEL6 and RHEL7 in one cluster
......................................................................

core: disable the mixing of RHEL6 and RHEL7 in one cluster

WIP - missing tests

Change-Id: Ieb6d41b1921a6caf946cba44a6c92ef86fef6bc8
Bug-Url: https://bugzilla.redhat.com/
Signed-off-by: Tomas Jelinek <[email protected]>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MonitoringStrategyFactory.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategy.java
M 
backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/MultipleServicesMonitoringStrategyTest.java
M 
backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategyTest.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
M 
frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
M packaging/dbscripts/vds_sp.sql
12 files changed, 72 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/11/34411/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index ec0eab9..cd13218 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -939,6 +939,10 @@
     EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER_LEVEL(9609, 
AuditLogSeverity.WARNING,
             AuditLogTimeInterval.MINUTE.getValue()),
 
+    MIXING_RHEL_VERSIONS_IN_CLUSTER(9610, AuditLogSeverity.WARNING,
+            AuditLogTimeInterval.MINUTE.getValue()),
+
+
     /** Highly available virtual machine went down. */
     HA_VM_FAILED(9602, AuditLogSeverity.ERROR),
     /** Restart of a highly available virtual machine failed. */
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java
index 1648308..0dfbf9e 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java
@@ -24,7 +24,9 @@
     ARCHITECTURE_INCOMPATIBLE_WITH_CLUSTER(16),
     NETWORK_INTERFACE_IS_DOWN(17),
     RNG_SOURCES_INCOMPATIBLE_WITH_CLUSTER(18),
-    EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER_LEVEL(19);
+    EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER_LEVEL(19),
+    MIXING_RHEL_VERSIONS_IN_CLUSTER(20);
+
 
     private final int value;
 
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java
index 0098504..0b689f2 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAO.java
@@ -209,4 +209,11 @@
      * @return the list of VDS instances
      */
     List<VDS> getHostsForStorageOperation(Guid storagePoolId, boolean 
localFsOnly);
+
+    /**
+     * Finds the first VDS which has host_os which starts with RHEL and the 
status is UP
+     * @param vdsGroupId cluster id
+     * @return first host or null, there are none such hosts
+     */
+    VDS getFirstUpRhelForVdsGroup(Guid vdsGroupId);
 }
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 e235806..95a218e 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
@@ -148,6 +148,16 @@
     }
 
     @Override
+    public VDS getFirstUpRhelForVdsGroup(Guid vdsGroupId) {
+        List<VDS> vds = 
getCallsHandler().executeReadList("getFirstUpRhelForVdsGroupId",
+                VdsRowMapper.instance,
+                getCustomMapSqlParameterSource()
+                        .addValue("vds_group_id", vdsGroupId));
+
+        return vds.size() != 0 ? vds.iterator().next() : null;
+    }
+
+    @Override
     public List<VDS> getAllForStoragePool(Guid storagePool) {
         return getAllForStoragePool(storagePool, null, false);
     }
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index f86f5b1..5c8d45a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -687,6 +687,7 @@
 VDS_SET_NON_OPERATIONAL_VM_NETWORK_IS_BRIDGELESS=Host ${VdsName} does not 
comply with the cluster ${VdsGroupName} networks, the following VM networks are 
non-VM networks: '${Networks}'
 EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER=Host ${VdsName} does not comply 
with the cluster ${VdsGroupName} emulated machine. The cluster emulated machine 
is ${clusterEmulatedMachines} and the host emulated machines are 
${hostSupportedEmulatedMachines}.
 EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER_LEVEL=Host ${VdsName} does not 
comply with the cluster ${VdsGroupName} emulated machines. The current cluster 
compatibility level supports ${clusterEmulatedMachines} and the host emulated 
machines are ${hostSupportedEmulatedMachines}.
+MIXING_RHEL_VERSIONS_IN_CLUSTER=It is not possible to mix RHEL 6x with RHEL 7x 
in one cluster. Host ${VdsName} has version ${addingRhel} while there are hosts 
with version ${previousRhel}.
 RNG_SOURCES_INCOMPATIBLE_WITH_CLUSTER=Host ${VdsName} does not comply with the 
cluster ${VdsGroupName} Random Number Generator sources. The Hosts supported 
sources are: ${hostSupportedRngSources}; and the cluster requirements are: 
${clusterRequiredRngSources}.
 # NUMA Messages
 NUMA_ADD_VM_NUMA_NODE_SUCCESS=Add VM NUMA node successfully.
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MonitoringStrategyFactory.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MonitoringStrategyFactory.java
index 8cdb76b..73a5a8b 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MonitoringStrategyFactory.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/MonitoringStrategyFactory.java
@@ -10,7 +10,7 @@
  * This class is responsible for returning the correct service strategy, 
according to the service the cluster supports
  */
 public class MonitoringStrategyFactory {
-    private static MonitoringStrategy virtMonitoringStrategy = new 
VirtMonitoringStrategy(DbFacade.getInstance().getVdsGroupDao());
+    private static MonitoringStrategy virtMonitoringStrategy = new 
VirtMonitoringStrategy(DbFacade.getInstance().getVdsGroupDao(), 
DbFacade.getInstance().getVdsDao());
     private static MonitoringStrategy glusterMonitoringStrategy = new 
GlusterMonitoringStrategy();
     private static MultipleServicesMonitoringStrategy 
multipleMonitoringStrategy = new MultipleServicesMonitoringStrategy();
 
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategy.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategy.java
index c2e9529..b587ead 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategy.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategy.java
@@ -16,6 +16,7 @@
 import org.ovirt.engine.core.common.utils.ListUtils;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+import org.ovirt.engine.core.dao.VdsDAO;
 import org.ovirt.engine.core.dao.VdsGroupDAO;
 
 /**
@@ -25,8 +26,11 @@
 
     private final VdsGroupDAO vdsGroupDao;
 
-    protected VirtMonitoringStrategy(VdsGroupDAO vdsGroupDao) {
+    private final VdsDAO vdsDao;
+
+    protected VirtMonitoringStrategy(VdsGroupDAO vdsGroupDao, VdsDAO vdsDao) {
         this.vdsGroupDao = vdsGroupDao;
+        this.vdsDao = vdsDao;
     }
 
     @Override
@@ -67,6 +71,28 @@
 
             vds.setStatus(VDSStatus.NonOperational);
         }
+        if (vds.getStatus() != VDSStatus.NonOperational) {
+            String[] hostOsInfo = vds.getHostOs().split("-");
+            String osName = hostOsInfo[0].trim();
+            String newVersion = hostOsInfo[1].trim();
+            if (osName.equals("RHEL")) {
+                VDS beforeRhel = 
vdsDao.getFirstUpRhelForVdsGroup(vdsGroup.getId());
+                boolean firstHostInCluster = beforeRhel == null;
+                if (!firstHostInCluster) {
+                    // if not first host in cluster, need to check if the 
version is the same
+                    String[] prevOsInfo = beforeRhel.getHostOs().split("-");
+                    String prevVersion = prevOsInfo[1].trim();
+                    boolean addingRhel6toRhel7 = newVersion.startsWith("6") && 
prevVersion.startsWith("7");
+                    boolean addingRhel7toRhel6 = newVersion.startsWith("7") && 
prevVersion.startsWith("6");
+                    if (addingRhel7toRhel6 || addingRhel6toRhel7) {
+                        Map<String, String> customLogValues = new HashMap<>();
+                        customLogValues.put("previousRhel", 
beforeRhel.getHostOs());
+                        customLogValues.put("addingRhel", vds.getHostOs());
+                        vdsNonOperational(vds, 
NonOperationalReason.MIXING_RHEL_VERSIONS_IN_CLUSTER, customLogValues);
+                    }
+                }
+            }
+        }
 
         if (!hostCompliesWithRngDeviceSources(vds, vdsGroup) && 
vds.getStatus() != VDSStatus.NonOperational) {
             Map<String, String> customLogValues = new HashMap<>();
diff --git 
a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/MultipleServicesMonitoringStrategyTest.java
 
b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/MultipleServicesMonitoringStrategyTest.java
index 8421f82..e2a2fa9 100644
--- 
a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/MultipleServicesMonitoringStrategyTest.java
+++ 
b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/MultipleServicesMonitoringStrategyTest.java
@@ -16,6 +16,7 @@
 import org.ovirt.engine.core.common.businessentities.NonOperationalReason;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
+import org.ovirt.engine.core.dao.VdsDAO;
 import org.ovirt.engine.core.dao.VdsGroupDAO;
 
 public class MultipleServicesMonitoringStrategyTest {
@@ -27,7 +28,7 @@
     public ExpectedException exception = ExpectedException.none();
 
     public MultipleServicesMonitoringStrategyTest() {
-        virtStrategy = spy(new 
VirtMonitoringStrategy(mock(VdsGroupDAO.class)));
+        virtStrategy = spy(new VirtMonitoringStrategy(mock(VdsGroupDAO.class), 
mock(VdsDAO.class)));
         glusterStrategy = spy(new GlusterMonitoringStrategy());
         doNothing().when(virtStrategy).vdsNonOperational(any(VDS.class), 
any(NonOperationalReason.class), any(Map.class));
         strategy = spy(new MultipleServicesMonitoringStrategy());
diff --git 
a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategyTest.java
 
b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategyTest.java
index 2beeecf..86586ff 100644
--- 
a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategyTest.java
+++ 
b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VirtMonitoringStrategyTest.java
@@ -16,12 +16,13 @@
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VmRngDevice;
 import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dao.VdsDAO;
 import org.ovirt.engine.core.dao.VdsGroupDAO;
 
 public class VirtMonitoringStrategyTest {
 
     public VirtMonitoringStrategyTest() {
-        virtStrategy = spy(new VirtMonitoringStrategy(mockVdsGroup()));
+        virtStrategy = spy(new VirtMonitoringStrategy(mockVdsGroup(), 
mock(VdsDAO.class)));
         doNothing().when(virtStrategy).vdsNonOperational(any(VDS.class), 
any(NonOperationalReason.class), any(Map.class));
     }
 
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
index fd06a63..bdcbbc8 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
@@ -40,6 +40,8 @@
 
     String 
NonOperationalReason___EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER_LEVEL();
 
+    String NonOperationalReason___MIXING_RHEL_VERSIONS_IN_CLUSTER();
+
     String NonOperationalReason___ARCHITECTURE_INCOMPATIBLE_WITH_CLUSTER();
 
     String NonOperationalReason___NETWORK_INTERFACE_IS_DOWN();
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
index 03e3806..4289f4b 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
+++ 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
@@ -13,6 +13,7 @@
 NonOperationalReason___GLUSTER_HOST_UUID_ALREADY_EXISTS=Gluster UUID already 
exists.
 NonOperationalReason___EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER=The Host 
emulated machine flags doesn't match one of the cluster emulated machines.
 NonOperationalReason___EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER_LEVEL=The 
Host emulated machine flags doesn't match any of the emulated machines 
supported by the cluster level.
+NonOperationalReason___MIXING_RHEL_VERSIONS_IN_CLUSTER=Not possible to mix 
RHEL 6x and 7x hosts in one cluster.
 NonOperationalReason___RNG_SOURCES_INCOMPATIBLE_WITH_CLUSTER=The Host 
supported Random Number Generator sources doesn't comply with sources required 
by Cluster.
 NonOperationalReason___UNTRUSTED=Host is untrusted.
 NonOperationalReason___UNINITIALIZED=Host is uninitialized as it is not 
attested yet.
diff --git a/packaging/dbscripts/vds_sp.sql b/packaging/dbscripts/vds_sp.sql
index 15f5442..64ae5f5 100644
--- a/packaging/dbscripts/vds_sp.sql
+++ b/packaging/dbscripts/vds_sp.sql
@@ -1120,3 +1120,15 @@
    RETURN;
 END; $procedure$
 LANGUAGE plpgsql;
+
+
+Create or replace FUNCTION getFirstUpRhelForVdsGroupId(v_vds_group_id UUID) 
RETURNS SETOF vds STABLE
+   AS $procedure$
+BEGIN
+   BEGIN
+      RETURN QUERY select * from vds where host_os ilike 'RHEL%' and status = 
3 LIMIT 1;
+   END;
+
+   RETURN;
+END; $procedure$
+LANGUAGE plpgsql;


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

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

Reply via email to