Martin Peřina has uploaded a new change for review.

Change subject: webadmin: Adds warning when upgrading cluster level
......................................................................

webadmin: Adds warning when upgrading cluster level

Adds warning when upgrading cluster level which contains some non
responsive hosts, that these hosts may become non operational after
connectivity is restored.

Change-Id: I88f47dd84c030bcd723f41c7973c4dae32df9f2e
Bug-Url: https://bugzilla.redhat.com/953532
Signed-off-by: Martin Perina <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
2 files changed, 58 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/58/17958/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
index 5b8f68c..503515e 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
@@ -13,9 +13,11 @@
 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.VM;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
 import org.ovirt.engine.core.common.interfaces.SearchType;
+import org.ovirt.engine.core.common.queries.IdQueryParameters;
 import org.ovirt.engine.core.common.queries.SearchParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
@@ -56,6 +58,7 @@
 
     private UICommand privateNewCommand;
     private boolean clusterPolicyFirst;
+
 
     public UICommand getNewCommand()
     {
@@ -522,19 +525,14 @@
         }
     }
 
-    private void onSaveConfirmCV(ClusterModel model)
-    {
+    private void onSaveConfirmCV(ClusterModel model) {
         if (!((Version) 
model.getVersion().getSelectedItem()).equals(((VDSGroup) 
getSelectedItem()).getcompatibility_version())) {
-            ConfirmationModel confirmModel = new ConfirmationModel();
+            final ConfirmationModel confirmModel = new ConfirmationModel();
             setConfirmWindow(confirmModel);
             confirmModel.setTitle(ConstantsManager.getInstance()
                     .getConstants()
                     .changeClusterCompatibilityVersionTitle());
             confirmModel.setHashName("change_cluster_compatibility_version"); 
//$NON-NLS-1$
-            confirmModel.setMessage(ConstantsManager.getInstance()
-                    .getConstants()
-                    .youAreAboutChangeClusterCompatibilityVersionMsg());
-
             UICommand tempVar = new UICommand("OnSaveConfirmCpuThreads", 
this); //$NON-NLS-1$
             
tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok());
             tempVar.setIsDefault(true);
@@ -543,6 +541,7 @@
             
tempVar2.setTitle(ConstantsManager.getInstance().getConstants().cancel());
             tempVar2.setIsCancel(true);
             getConfirmWindow().getCommands().add(tempVar2);
+            checkForNonResponsiveHosts(confirmModel);
         } else {
             onSaveConfirmCpuThreads();
         }
@@ -1002,4 +1001,51 @@
     protected String getListName() {
         return "ClusterListModel"; //$NON-NLS-1$
     }
+
+    /**
+     * Checks if in selected cluster are some non responsive hosts. If so, it 
adds warning about upgrading cluster level
+     * when some hosts are non responsive
+     */
+    @SuppressWarnings("unchecked")
+    private void checkForNonResponsiveHosts(final ConfirmationModel 
confirmModel) {
+        startProgress(null);
+        Frontend.RunQuery(VdcQueryType.GetHostsByClusterId,
+                new IdQueryParameters(((VDSGroup) getSelectedItem()).getId()),
+                new AsyncQuery(this, new INewAsyncCallback() {
+
+                    @Override
+                    public void onSuccess(Object target, Object returnValue) {
+                        ClusterListModel model = (ClusterListModel) target;
+                        ArrayList<VDS> hosts = null;
+                        if (returnValue instanceof ArrayList) {
+                            hosts = (ArrayList<VDS>) returnValue;
+                        } else if (returnValue instanceof VdcQueryReturnValue
+                                && ((VdcQueryReturnValue) 
returnValue).getReturnValue() instanceof ArrayList) {
+                            hosts = (ArrayList<VDS>) ((VdcQueryReturnValue) 
returnValue).getReturnValue();
+                        } else {
+                            throw new IllegalArgumentException("The return 
value should be ArrayList<VDS> or VdcQueryReturnValue with return value 
ArrayList<VDS>"); //$NON-NLS-1$
+                        }
+
+                        boolean result = false;
+                        for (VDS host : hosts) {
+                            if (VDSStatus.NonResponsive == host.getStatus()) {
+                                result = true;
+                                break;
+                            }
+                        }
+
+                        if (result) {
+                            
confirmModel.setMessage(ConstantsManager.getInstance()
+                                    .getConstants()
+                                    
.youAreAboutChangeClusterCompatibilityVersionNonResponsiveHostsMsg());
+                        } else {
+                            
confirmModel.setMessage(ConstantsManager.getInstance()
+                                    .getConstants()
+                                    
.youAreAboutChangeClusterCompatibilityVersionMsg());
+                        }
+
+                        model.stopProgress();
+                    }
+                }));
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
index 973cf90..9da4737 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
@@ -641,6 +641,11 @@
     @DefaultStringValue("You are about to change the Cluster Compatibility 
Version. Are you sure you want to continue?")
     String youAreAboutChangeClusterCompatibilityVersionMsg();
 
+    @DefaultStringValue("You are about to change the Cluster Compatibility 
Version and the cluster contains some non"
+            + " responsive hosts. If these hosts do not support the selected 
compatibility level they may move to non"
+            + " operational after connectivity is restored.\n\nAre you sure 
you want to continue?")
+    String youAreAboutChangeClusterCompatibilityVersionNonResponsiveHostsMsg();
+
     @DefaultStringValue("Moving Quota to Enforce Mode\n" +
             "All the templates, virtual machines, and disks must be assigned 
into specific quota allocations otherwise will be unusable.\nUsers should be 
added as quota consumers.\n\n" +
             "Please consider using Audit mode until you define Quotas for the 
users.\n\n" +


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

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

Reply via email to