Piotr Kliczewski has uploaded a new change for review.

Change subject: jsonrpc: Protocol decision based on cluser compatibility version
......................................................................

jsonrpc: Protocol decision based on cluser compatibility version

Engine decides which protocol to use depending on cluster compatibility
version when there was no manual protocol override (UI or REST). When
cluser compatibility verions is set to 3.5 or higher jsonrpc over stomp
is used and for older versions xmlrpc is used.

Next step is to disable user override option when we confirm that
jsonrpc is stable enough.

Bug-Url: https://bugzilla.redhat.com/1081049
Change-Id: I63e857be667095f62de7ed5e6a81b25a41e917f4
Signed-off-by: pkliczewski <piotr.kliczew...@gmail.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStatisticsDAOTest.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
M packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
10 files changed, 63 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/31229/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java
index 7606b4a..6ba992b 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java
@@ -21,6 +21,7 @@
 import org.ovirt.engine.core.bll.utils.GlusterUtil;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.common.FeatureSupported;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.AddVdsActionParameters;
 import org.ovirt.engine.core.common.action.InstallVdsParameters;
@@ -33,8 +34,11 @@
 import org.ovirt.engine.core.common.businessentities.Provider;
 import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VdsDynamic;
+import org.ovirt.engine.core.common.businessentities.VdsProtocol;
+import org.ovirt.engine.core.common.businessentities.VdsStatic;
 import org.ovirt.engine.core.common.businessentities.VdsStatistics;
 import org.ovirt.engine.core.common.config.Config;
 import org.ovirt.engine.core.common.config.ConfigValues;
@@ -259,6 +263,15 @@
     private void AddVdsStaticToDb() {
         getParameters().getVdsStaticData().setServerSslEnabled(
                 Config.<Boolean> 
getValue(ConfigValues.EncryptHostCommunication));
+        VdsStatic vdsStatic = getParameters().getVdsStaticData();
+        if (vdsStatic.getProtocol() == null) {
+            VDSGroup cluster = getVdsGroup();
+            if (cluster != null && 
FeatureSupported.jsonProtocol(cluster.getcompatibility_version())) {
+                vdsStatic.setProtocol(VdsProtocol.STOMP);
+            } else {
+                vdsStatic.setProtocol(VdsProtocol.XML);
+            }
+        }
         
DbFacade.getInstance().getVdsStaticDao().save(getParameters().getVdsStaticData());
         
getCompensationContext().snapshotNewEntity(getParameters().getVdsStaticData());
         setVdsIdRef(getParameters().getVdsStaticData().getId());
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
index eb7fb20..91000d3 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
@@ -385,4 +385,13 @@
         return supportedInConfig(ConfigValues.LiveMergeSupported, version);
 
     }
+
+    /**
+     * @param version
+     *            Compatibility version to check for.
+     * @return <code>true</code> if json protocol is supported for the given 
version.
+     */
+    public static boolean jsonProtocol(Version version) {
+        return supportedInConfig(ConfigValues.JsonProtocolSupported, version);
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
index f8dfccc..48ef6ff 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
@@ -193,7 +193,6 @@
         autoRecoverable = true;
         disablePowerManagementPolicy = false;
         pmKdumpDetection = true;
-        this.protocol = VdsProtocol.XML;
         this.hostProviderId = null;
     }
 
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
index 89f3a0a..bb928f5 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
@@ -1868,5 +1868,12 @@
     @DefaultValueAttribute("false")
     CSRFProtection,
 
-    Invalid
+    Invalid,
+
+    /**
+     * Specifies whether jsonrpc protocol is supported.
+     */
+    @TypeConverterAttribute(Boolean.class)
+    @DefaultValueAttribute("true")
+    JsonProtocolSupported
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
index 35fec2e..0e13d84 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java
@@ -136,7 +136,8 @@
     SpiceFileTransferToggleSupported(ConfigAuthType.User),
     SpiceCopyPasteToggleSupported(ConfigAuthType.User),
     DefaultMtu,
-    LiveMergeSupported(ConfigAuthType.User);
+    LiveMergeSupported(ConfigAuthType.User),
+    JsonProtocolSupported(ConfigAuthType.User);
 
     public static enum ConfigAuthType {
         Admin,
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
index 0c4b7dd..a97f5a9 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
@@ -7,6 +7,7 @@
 import org.junit.Test;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VdsDynamic;
+import org.ovirt.engine.core.common.businessentities.VdsProtocol;
 import org.ovirt.engine.core.common.businessentities.VdsStatic;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.RpmVersion;
@@ -31,6 +32,7 @@
         newStaticVds = new VdsStatic();
         newStaticVds.setHostName("farkle.redhat.com");
         newStaticVds.setVdsGroupId(existingVds.getVdsGroupId());
+        newStaticVds.setProtocol(VdsProtocol.STOMP);
         newDynamicVds = new VdsDynamic();
     }
 
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
index ab7c873..e16ed1d 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
@@ -10,6 +10,7 @@
 
 import org.junit.Test;
 import org.ovirt.engine.core.common.businessentities.VdsDynamic;
+import org.ovirt.engine.core.common.businessentities.VdsProtocol;
 import org.ovirt.engine.core.common.businessentities.VdsStatic;
 import org.ovirt.engine.core.common.businessentities.VdsStatistics;
 import org.ovirt.engine.core.compat.Guid;
@@ -37,6 +38,7 @@
         newStaticVds.setVdsGroupId(existingVds.getVdsGroupId());
         
newStaticVds.setSshKeyFingerprint("b5:ad:16:19:06:9f:b3:41:69:eb:1c:42:1d:12:b5:31");
         newStaticVds.setPmSecondaryOptionsMap(new HashMap<String, String>());
+        newStaticVds.setProtocol(VdsProtocol.STOMP);
     }
 
     /**
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStatisticsDAOTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStatisticsDAOTest.java
index c54e879..8df7203 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStatisticsDAOTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStatisticsDAOTest.java
@@ -5,6 +5,7 @@
 import static org.junit.Assert.assertNull;
 
 import org.junit.Test;
+import org.ovirt.engine.core.common.businessentities.VdsProtocol;
 import org.ovirt.engine.core.common.businessentities.VdsStatic;
 import org.ovirt.engine.core.common.businessentities.VdsStatistics;
 import org.ovirt.engine.core.compat.Guid;
@@ -29,6 +30,7 @@
         newStaticVds = new VdsStatic();
         newStaticVds.setHostName("farkle.redhat.com");
         newStaticVds.setVdsGroupId(existingVds.getVdsGroupId());
+        newStaticVds.setProtocol(VdsProtocol.STOMP);
         newStatistics = new VdsStatistics();
 
     }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
index 0940dec..1a2b7b4 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
@@ -679,6 +679,25 @@
             }
         });
 
+        hostModel.getCluster().getSelectedItemChangedEvent().addListener(new 
IEventListener() {
+
+            @Override
+            public void eventRaised(Event ev, Object sender, EventArgs args) {
+                ListModel<VDSGroup> clusterModel = hostModel.getCluster();
+                if (clusterModel.getSelectedItem() != null) {
+                    VDSGroup cluster = clusterModel.getSelectedItem();
+                    Boolean jsonSupported =
+                            (Boolean) 
AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigurationValues.JsonProtocolSupported,
+                                    
cluster.getcompatibility_version().toString());
+                    if (jsonSupported) {
+                        hostModel.getProtocol().setEntity(true);
+                    } else {
+                        hostModel.getProtocol().setEntity(false);
+                    }
+                }
+            }
+        });
+
         AsyncQuery _asyncQuery = new AsyncQuery();
         _asyncQuery.setModel(this);
         _asyncQuery.asyncCallback = new INewAsyncCallback() {
diff --git a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql 
b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
index 98b74ae..386475d 100644
--- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
+++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
@@ -322,6 +322,12 @@
 select fn_db_add_config_value('StoragePoolMemoryBackend','false','3.3');
 select fn_db_add_config_value('StoragePoolMemoryBackend','false','3.4');
 
+select fn_db_add_config_value('JsonProtocolSupported','false','3.0');
+select fn_db_add_config_value('JsonProtocolSupported','false','3.1');
+select fn_db_add_config_value('JsonProtocolSupported','false','3.2');
+select fn_db_add_config_value('JsonProtocolSupported','false','3.3');
+select fn_db_add_config_value('JsonProtocolSupported','false','3.4');
+
 -- by default use no proxy
 select fn_db_add_config_value('SpiceProxyDefault','','general');
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I63e857be667095f62de7ed5e6a81b25a41e917f4
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Piotr Kliczewski <piotr.kliczew...@gmail.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to