Yaniv Bronhaim has uploaded a new change for review.

Change subject: Enable json rpc based on cluster level when deploying foreman's 
hosts
......................................................................

Enable json rpc based on cluster level when deploying foreman's hosts

Reusing hostModel.getCluster().getSelectedItemChangedEvent() code in
NewHostModel listeners. setProtocolValue will pick jsonrpc by default if
picked cluster level supports it.

Change-Id: Ia7eadb533dd02698f07103fa61e076b46d054522
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1178009
Signed-off-by: Yaniv Bronhaim <ybron...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NewHostModel.java
3 files changed, 24 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/36631/1

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 bab682a..05bbfc6 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
@@ -697,20 +697,8 @@
         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.getConfigValuePreConverted(ConfigurationValues.JsonProtocolSupported,
-                                    
cluster.getcompatibility_version().toString());
-                    if (jsonSupported) {
-                        hostModel.getProtocol().setEntity(true);
-                    } else {
-                        hostModel.getProtocol().setEntity(false);
-                        hostModel.getProtocol().setIsChangable(false);
-                    }
-                }
+            public void eventRaised(Event<? extends EventArgs> ev, Object 
sender, EventArgs args) {
+                hostModel.setProtocolValue();
             }
         });
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
index ce13ee6..17bc710 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java
@@ -19,6 +19,7 @@
 import org.ovirt.engine.core.common.businessentities.VdsProtocol;
 import org.ovirt.engine.core.common.businessentities.VdsStatic;
 import org.ovirt.engine.core.common.mode.ApplicationMode;
+import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.core.common.queries.GetNewVdsFenceStatusParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
@@ -1879,6 +1880,23 @@
         }
     }
 
+    protected void setProtocolValue() {
+        // Set Host protocol based on cluster level. If cluster level supports 
jsonrpc, use that by default.
+        ListModel<VDSGroup> clusterModel = getCluster();
+        if (clusterModel.getSelectedItem() != null) {
+            VDSGroup cluster = clusterModel.getSelectedItem();
+            Boolean jsonSupported =
+                    (Boolean) 
AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigurationValues.JsonProtocolSupported,
+                            cluster.getcompatibility_version().toString());
+            if (jsonSupported) {
+                getProtocol().setEntity(true);
+            } else {
+                getProtocol().setEntity(false);
+                getProtocol().setIsChangable(false);
+            }
+        }
+    }
+
     public void cleanHostParametersFields() {
         getName().setEntity(constants.empty());
         getComment().setEntity(constants.empty());
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NewHostModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NewHostModel.java
index 52bdbb3..e800bb4 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NewHostModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/NewHostModel.java
@@ -85,7 +85,8 @@
         VDS vds = (VDS) getExternalHostName().getSelectedItem();
         if (vds == null) {
             vds = new VDS();
-        }
+       }
+        setProtocolValue();
         updateModelFromVds(vds, null, false, null);
     }
 
@@ -97,6 +98,7 @@
             vds.setVdsName(dhost.getName());
             vds.setHostName(dhost.getName() + "." + dhg.getDomainName()); 
//$NON-NLS-1$
         }
+        setProtocolValue();
         updateModelFromVds(vds, null, false, null);
     }
 
@@ -107,6 +109,7 @@
             vds.setVdsName(getName().getEntity());
             vds.setHostName(getName().getEntity() + "." + 
dhg.getDomainName()); //$NON-NLS-1$
         }
+        setProtocolValue();
         updateModelFromVds(vds, null, false, null);
     }
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia7eadb533dd02698f07103fa61e076b46d054522
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Yaniv Bronhaim <ybron...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to