Kanagaraj M has uploaded a new change for review.

Change subject: webadmin: check UP server before adding bricks
......................................................................

webadmin: check UP server before adding bricks

While adding the bricks after creating a volume, Add Bricks
dialog will be shown only if the cluster has a host in UP status.
Otherwise an error message denoting no up server found in the cluster
will be shown.

Change-Id: I54b3c0eacbe4c94929d20738196324569ed8f3b6
Bug-Url: https://bugzilla.redhat.com/907338
Signed-off-by: Kanagaraj M <kmayi...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java
3 files changed, 55 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/27/11927/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index 351aaf5..37484d1 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -36,6 +36,7 @@
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface;
 import org.ovirt.engine.core.common.businessentities.VmOsType;
+import org.ovirt.engine.core.common.businessentities.VmPool;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
 import org.ovirt.engine.core.common.businessentities.VmTemplateStatus;
 import org.ovirt.engine.core.common.businessentities.VolumeFormat;
@@ -44,7 +45,6 @@
 import org.ovirt.engine.core.common.businessentities.storage_domains;
 import org.ovirt.engine.core.common.businessentities.storage_pool;
 import org.ovirt.engine.core.common.businessentities.tags;
-import org.ovirt.engine.core.common.businessentities.VmPool;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
@@ -55,7 +55,6 @@
 import org.ovirt.engine.core.common.queries.CommandVersionsInfo;
 import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.core.common.queries.GetAllAttachableDisks;
-import org.ovirt.engine.core.common.queries.InterfaceAndIdQueryParameters;
 import org.ovirt.engine.core.common.queries.GetAllDisksByVmIdParameters;
 import 
org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters;
 import 
org.ovirt.engine.core.common.queries.GetAllImagesListByStoragePoolIdParameters;
@@ -83,6 +82,7 @@
 import 
org.ovirt.engine.core.common.queries.GetVmTemplatesByStoragePoolIdParameters;
 import org.ovirt.engine.core.common.queries.GetVmTemplatesDisksParameters;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
+import org.ovirt.engine.core.common.queries.InterfaceAndIdQueryParameters;
 import 
org.ovirt.engine.core.common.queries.IsVmPoolWithSameNameExistsParameters;
 import 
org.ovirt.engine.core.common.queries.IsVmTemlateWithSameNameExistParameters;
 import org.ovirt.engine.core.common.queries.IsVmWithSameNameExistParameters;
@@ -1126,6 +1126,24 @@
                 aQuery);
     }
 
+    public static void isClusterHasAnyUpHost(AsyncQuery aQuery, Guid 
clusterId) {
+        aQuery.converterCallback = new IAsyncConverter() {
+            @Override
+            public Object Convert(Object source, AsyncQuery _asyncQuery)
+            {
+                if (source != null) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        };
+        Frontend.RunQuery(VdcQueryType.GetVdsInUpStatusByVdsGroupId,
+                new IdQueryParameters(clusterId),
+                aQuery);
+    }
+
     public static void GetRpmVersionViaPublic(AsyncQuery aQuery) {
         aQuery.converterCallback = new IAsyncConverter() {
             @Override
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java
index c83cfd5..7d6ea3f 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeBrickListModel.java
@@ -160,19 +160,44 @@
         OnEntityChanged();
     }
 
-    private void addBricks() {
-
-        if (getWindow() != null)
-        {
+    private void checkUpServerAndAddBricks() {
+        if (getWindow() != null) {
             return;
         }
 
         GlusterVolumeEntity volumeEntity = (GlusterVolumeEntity) getEntity();
 
-        if (volumeEntity == null)
-        {
+        if (volumeEntity == null) {
             return;
         }
+
+        AsyncDataProvider.isClusterHasAnyUpHost(new AsyncQuery(volumeEntity, 
new INewAsyncCallback() {
+            @Override
+            public void OnSuccess(Object entity, Object returnValue) {
+                boolean clusterHasUpHost = (Boolean) returnValue;
+                if (clusterHasUpHost) {
+                    addBricks((GlusterVolumeEntity) entity);
+                }
+                else {
+                    ConfirmationModel model = new ConfirmationModel();
+                    setWindow(model);
+                    
model.setTitle(ConstantsManager.getInstance().getConstants().addBricksVolume());
+                    model.setMessage(ConstantsManager.getInstance()
+                            .getConstants()
+                            .cannotAddBricksNoUpServerFound());
+                    model.setHashName("cannot_add_bricks"); //$NON-NLS-1$
+
+                    UICommand command = new UICommand("Cancel", 
VolumeBrickListModel.this); //$NON-NLS-1$
+                    
command.setTitle(ConstantsManager.getInstance().getConstants().close());
+                    command.setIsCancel(true);
+                    model.getCommands().add(command);
+                    return;
+                }
+            }
+        }), volumeEntity.getClusterId());
+    }
+
+    private void addBricks(GlusterVolumeEntity volumeEntity) {
 
         VolumeBrickModel volumeBrickModel = new VolumeBrickModel();
 
@@ -806,7 +831,7 @@
     public void ExecuteCommand(UICommand command) {
         super.ExecuteCommand(command);
         if (command.equals(getAddBricksCommand())) {
-            addBricks();
+            checkUpServerAndAddBricks();
         } else if (command.getName().equals("OnAddBricks")) { //$NON-NLS-1$
             onAddBricks();
         } else if (command.getName().equals("OnAddBricksInternal")) { 
//$NON-NLS-1$
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java
index 0d489a7..b6fc69b 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java
@@ -1418,6 +1418,9 @@
     @DefaultStringValue("Replace Brick")
     String replaceBrickTitle();
 
+    @DefaultStringValue("Could not find any host in Up status in the cluster. 
Please try again later.")
+    String cannotAddBricksNoUpServerFound();
+
     @DefaultStringValue("Brick Details")
     String advancedDetailsBrickTitle();
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I54b3c0eacbe4c94929d20738196324569ed8f3b6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Kanagaraj M <kmayi...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to