Gustavo Frederico Temple Pedrosa has uploaded a new change for review.

Change subject: userportal, webadmin: [Fix] Disable per arch the Pool SPICE 
proxy
......................................................................

userportal, webadmin: [Fix] Disable per arch the Pool SPICE proxy

This patch changes disable the Pool SPICE proxy if is not compatible
with the architecture of the Cluster.

Change-Id: Ifb2c22954a411206ac39dee05f08432e21989b16
Signed-off-by: Gustavo Pedrosa <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/EntityModelWidgetWithInfo.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/pool/BasePoolPopupPresenterWidget.java
5 files changed, 68 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/53/25753/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
index 193e4d4..85edcb9 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
@@ -129,6 +129,9 @@
     @DefaultMessage("Map control-alt-del shortcut to {0}")
     String remapCtrlAltDelete(String hotkey);
 
+    @DefaultMessage("SPICE proxy is disabled because is not compatible with 
the architecture of the selected Cluster.")
+    String consoleOverrideSpiceProxyMessageNotCompatibleOnCluster();
+
     @DefaultMessage("This will override the SPICE proxy defined in {0}. 
Current configuration: {1}.")
     String consoleOverrideSpiceProxyMessage(String parentConfiguration, String 
parentSpiceProxy);
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/EntityModelWidgetWithInfo.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/EntityModelWidgetWithInfo.java
index cdd5b93..846a801 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/EntityModelWidgetWithInfo.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/EntityModelWidgetWithInfo.java
@@ -21,6 +21,21 @@
 
     private static CommonApplicationResources resources = 
GWT.create(CommonApplicationResources.class);
 
+    private enum LabelColors {
+        DISABLED("gray"),  //$NON-NLS-1$
+        ENABLED("#333333");  //$NON-NLS-1$
+
+        private final String color;
+
+        private LabelColors(String color) {
+            this.color = color;
+        }
+
+        public String color() {
+            return this.color;
+        }
+    }
+
     @UiField(provided = true)
     EntityModelLabel label;
 
@@ -43,4 +58,12 @@
         infoIcon.setText(text);
     }
 
+    public void setLabelEnabled(boolean enabled) {
+        if (enabled) {
+            
this.label.getElement().getStyle().setColor(LabelColors.ENABLED.color());
+        } else {
+            
this.label.getElement().getStyle().setColor(LabelColors.DISABLED.color());
+        }
+    }
+
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
index f82dc0e..465d520 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
@@ -1285,6 +1285,23 @@
                 }
             }
         });
+
+        
object.getDataCenterWithClustersList().getPropertyChangedEvent().addListener(new
 IEventListener() {
+            @Override
+            public void eventRaised(Event ev, Object sender, EventArgs args) {
+                boolean hasSpiceSupport = object.hasSpiceSupport();
+
+                object.getSpiceProxyEnabled().setIsChangable(hasSpiceSupport);
+                
spiceProxyEnabledCheckboxWithInfoIcon.setLabelEnabled(hasSpiceSupport);
+
+                if (!hasSpiceSupport) {
+                    object.getSpiceProxyEnabled().setEntity(hasSpiceSupport);
+                    object.getSpiceProxy().setIsChangable(hasSpiceSupport);
+                    object.getSpiceProxy().setEntity("");
+                }
+            }
+        });
+
     }
 
     /**
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
index dd10495..b8b0c79 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
@@ -1846,6 +1846,17 @@
         behavior.postDisplayTypeItemChanged(oldDisplayProtocolOption);
     }
 
+    public boolean hasSpiceSupport() {
+        VDSGroup cluster = getSelectedCluster();
+        Integer osType = getOSType().getSelectedItem();
+
+        if (cluster == null || osType == null) {
+            return true;
+        }
+
+        return AsyncDataProvider.hasSpiceSupport(osType, 
cluster.getcompatibility_version());
+    }
+
     private void initFirstBootDevice()
     {
         EntityModel tempVar = new EntityModel();
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/pool/BasePoolPopupPresenterWidget.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/pool/BasePoolPopupPresenterWidget.java
index a032a00..597eed0 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/pool/BasePoolPopupPresenterWidget.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/pool/BasePoolPopupPresenterWidget.java
@@ -5,9 +5,11 @@
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.core.compat.StringHelper;
+import org.ovirt.engine.core.compat.Version;
 import org.ovirt.engine.ui.common.CommonApplicationMessages;
 import 
org.ovirt.engine.ui.common.widget.popup.AbstractVmBasedPopupPresenterWidget;
 import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
+import org.ovirt.engine.ui.uicommonweb.models.ListModel;
 import org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel;
 import org.ovirt.engine.ui.uicompat.Event;
 import org.ovirt.engine.ui.uicompat.EventArgs;
@@ -31,19 +33,28 @@
             @Override
             public void eventRaised(Event ev, Object sender, EventArgs args) {
                 if (model.getSelectedCluster() != null) {
-                    
setSpiceProxyOverrideExplanation(model.getSelectedCluster());
+                    
setSpiceProxyOverrideExplanation(model.getSelectedCluster(), model.getOSType());
                 }
 
             }
         });
     }
 
-    private void setSpiceProxyOverrideExplanation(VDSGroup selectedCluster) {
+    private void setSpiceProxyOverrideExplanation(VDSGroup selectedCluster, 
final ListModel<Integer> osType) {
         String spiceProxyInConfig =
                 (String) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.SpiceProxyDefault);
         String spiceProxyOnCluster = selectedCluster.getSpiceProxy();
+        Version version = selectedCluster.getcompatibility_version();
+        Integer osId = osType != null ? osType.getSelectedItem() : null;
+        boolean hasSpiceSupport = true;
 
-        if (!StringHelper.isNullOrEmpty(spiceProxyOnCluster)) {
+        if (version != null && osId != null) {
+            hasSpiceSupport = AsyncDataProvider.hasSpiceSupport(osId, 
selectedCluster.getcompatibility_version());
+        }
+
+        if (!hasSpiceSupport) {
+            
getView().setSpiceProxyOverrideExplanation(messages.consoleOverrideSpiceProxyMessageNotCompatibleOnCluster());
+        } else if (!StringHelper.isNullOrEmpty(spiceProxyOnCluster)) {
             
getView().setSpiceProxyOverrideExplanation(messages.consoleOverrideSpiceProxyMessage(messages.consoleOverrideDefinedOnCluster(),
                     spiceProxyOnCluster));
         } else if (!StringHelper.isNullOrEmpty(spiceProxyInConfig)) {


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

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

Reply via email to