Kanagaraj M has uploaded a new change for review.

Change subject: webadmin: [WIP] adding gluster volume remove brick status
......................................................................

webadmin: [WIP] adding gluster volume remove brick status

.

Change-Id: Iaed9cfeb52e990d2059b628598e1b82daf1d01e5
Signed-off-by: Kanagaraj M <[email protected]>
---
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/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeRebalanceStatusModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeBrickView.java
8 files changed, 102 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/78/20078/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 8f360fc..2cd6a3c 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
@@ -10,12 +10,14 @@
 import java.util.List;
 import java.util.Map;
 import java.util.MissingResourceException;
+
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.EventNotificationEntity;
 import org.ovirt.engine.core.common.TimeZoneType;
 import org.ovirt.engine.core.common.VdcEventNotificationUtils;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.VdcActionType;
+import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksQueriesParameters;
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
 import org.ovirt.engine.core.common.businessentities.DbUser;
 import org.ovirt.engine.core.common.businessentities.Disk;
@@ -49,7 +51,10 @@
 import org.ovirt.engine.core.common.businessentities.VmTemplateStatus;
 import org.ovirt.engine.core.common.businessentities.VolumeFormat;
 import org.ovirt.engine.core.common.businessentities.VolumeType;
+import org.ovirt.engine.core.common.businessentities.permissions;
+import org.ovirt.engine.core.common.businessentities.tags;
 import 
org.ovirt.engine.core.common.businessentities.comparators.NameableComparator;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterClusterService;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService;
@@ -62,8 +67,6 @@
 import 
org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface;
 import org.ovirt.engine.core.common.businessentities.network.VnicProfile;
 import org.ovirt.engine.core.common.businessentities.network.VnicProfileView;
-import org.ovirt.engine.core.common.businessentities.permissions;
-import org.ovirt.engine.core.common.businessentities.tags;
 import org.ovirt.engine.core.common.interfaces.SearchType;
 import org.ovirt.engine.core.common.mode.ApplicationMode;
 import org.ovirt.engine.core.common.queries.CommandVersionsInfo;
@@ -1356,6 +1359,21 @@
         Frontend.RunQuery(VdcQueryType.GetGlusterVolumeRebalanceStatus, 
parameters, aQuery);
     }
 
+    public static void getGlusterRemoveBrickStatus(AsyncQuery aQuery,
+            Guid clusterId,
+            Guid volumeId,
+            List<GlusterBrickEntity> bricks) {
+        aQuery.converterCallback = new 
IAsyncConverter<GlusterVolumeTaskStatusEntity>() {
+            @Override
+            public GlusterVolumeTaskStatusEntity Convert(Object source, 
AsyncQuery _asyncQuery) {
+                return (GlusterVolumeTaskStatusEntity) source;
+            }
+        };
+        GlusterVolumeRemoveBricksQueriesParameters parameters =
+                new GlusterVolumeRemoveBricksQueriesParameters(clusterId, 
volumeId, bricks);
+        Frontend.RunQuery(VdcQueryType.GetGlusterVolumeRemoveBricksStatus, 
parameters, 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 e1a889e..47f03cf 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
@@ -20,6 +20,7 @@
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterTaskOperation;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType;
 import org.ovirt.engine.core.common.businessentities.gluster.Mempool;
 import org.ovirt.engine.core.common.job.JobExecutionStatus;
@@ -54,6 +55,7 @@
         setRemoveBricksCommand(new UICommand("Remove Bricks", this)); 
//$NON-NLS-1$
         setStopRemoveBricksCommand(new UICommand("StopRemoveBricks", this)); 
//$NON-NLS-1$
         setCommitRemoveBricksCommand(new UICommand("CommitRemoveBricks", 
this)); //$NON-NLS-1$
+        setStatusRemoveBricksCommand(new UICommand("StatusRemoveBricks", 
this)); //$NON-NLS-1$
         setReplaceBrickCommand(new UICommand("Replace Brick", this)); 
//$NON-NLS-1$
         setBrickAdvancedDetailsCommand(new UICommand("Brick Advanced Details", 
this)); //$NON-NLS-1$
         getReplaceBrickCommand().setIsAvailable(false);
@@ -107,6 +109,18 @@
         commitRemoveBricksCommand = value;
     }
 
+    private UICommand statusRemoveBricksCommand;
+
+    public UICommand getStatusRemoveBricksCommand()
+    {
+        return statusRemoveBricksCommand;
+    }
+
+    private void setStatusRemoveBricksCommand(UICommand value)
+    {
+        statusRemoveBricksCommand = value;
+    }
+
     private UICommand replaceBrickCommand;
 
     public UICommand getReplaceBrickCommand()
@@ -151,6 +165,7 @@
         boolean allowRemove = true;
         boolean allowStopRemove = true;
         boolean allowCommitRemove = true;
+        boolean allowStatusRemove = true;
         boolean allowReplace = true;
         boolean allowAdvanced = true;
 
@@ -198,9 +213,14 @@
                         && volumeEntity.getAsyncTask().getType() == 
GlusterTaskType.REMOVE_BRICK
                         && volumeEntity.getAsyncTask().getStatus() == 
JobExecutionStatus.FINISHED;
 
+        allowStatusRemove =
+                volumeEntity != null && volumeEntity.getAsyncTask() != null
+                        && volumeEntity.getAsyncTask().getType() == 
GlusterTaskType.REMOVE_BRICK;
+
         getRemoveBricksCommand().setIsExecutionAllowed(allowRemove);
         getStopRemoveBricksCommand().setIsExecutionAllowed(allowStopRemove);
         
getCommitRemoveBricksCommand().setIsExecutionAllowed(allowCommitRemove);
+        
getStatusRemoveBricksCommand().setIsExecutionAllowed(allowStatusRemove);
         getReplaceBrickCommand().setIsExecutionAllowed(allowReplace);
         getBrickAdvancedDetailsCommand().setIsExecutionAllowed(allowAdvanced);
     }
@@ -898,6 +918,51 @@
                 model);
     }
 
+    private void showRemoveBricksStatus() {
+        if (getWindow() != null) {
+            return;
+        }
+
+        final GlusterVolumeEntity volumeEntity = (GlusterVolumeEntity) 
getEntity();
+        ArrayList<GlusterBrickEntity> bricks = new 
ArrayList<GlusterBrickEntity>();
+        for (GlusterBrickEntity brick : volumeEntity.getBricks()) {
+            if (brick.getAsyncTask() != null && 
brick.getAsyncTask().getTaskId() != null) {
+                bricks.add(brick);
+            }
+        }
+
+        AsyncDataProvider.getGlusterRemoveBrickStatus(new AsyncQuery(this, new 
INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object model, Object returnValue) {
+                GlusterVolumeTaskStatusEntity removeBrickStatusEntity = 
(GlusterVolumeTaskStatusEntity) returnValue;
+                VolumeRebalanceStatusModel rebalanceStatusModel = new 
VolumeRebalanceStatusModel(volumeEntity);
+                
rebalanceStatusModel.setTitle(ConstantsManager.getInstance().getConstants().removeBricksStatusTitle());
+
+                setWindow(rebalanceStatusModel);
+
+                
rebalanceStatusModel.getVolume().setEntity(volumeEntity.getName());
+                
rebalanceStatusModel.getCluster().setEntity(volumeEntity.getVdsGroupName());
+
+                rebalanceStatusModel.showStatus(removeBrickStatusEntity);
+
+                UICommand stopRebalanceFromStatus =
+                        new UICommand("StopRemoveBricksOnStatus", 
VolumeBrickListModel.this);//$NON-NLS-1$
+                
stopRebalanceFromStatus.setTitle(ConstantsManager.getInstance().getConstants().stopRemoveBricksButton());
+                
rebalanceStatusModel.getCommands().add(stopRebalanceFromStatus);
+
+                
stopRebalanceFromStatus.setIsExecutionAllowed(removeBrickStatusEntity.getStatusSummary().getStatus()
 == JobExecutionStatus.STARTED);
+
+                UICommand cancelCommand = new UICommand("Cancel", 
VolumeBrickListModel.this);//$NON-NLS-1$
+                
cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().close());
+                cancelCommand.setIsCancel(true);
+                rebalanceStatusModel.getCommands().add(cancelCommand);
+            }
+        }),
+                volumeEntity.getClusterId(),
+                volumeEntity.getId(),
+                bricks);
+    }
+
     private void replaceBrick()
     {
         if (getWindow() != null)
@@ -1116,6 +1181,8 @@
             commitRemoveBricks();
         } else if (command.getName().equals("OnCommitRemoveBricks")) { 
//$NON-NLS-1$
             onCommitRemoveBricks();
+        } else if (command.equals(getStatusRemoveBricksCommand())) {
+            showRemoveBricksStatus();
         } else if (command.equals(getReplaceBrickCommand())) {
             replaceBrick();
         } else if (command.getName().equals("OnReplace")) { //$NON-NLS-1$
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeRebalanceStatusModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeRebalanceStatusModel.java
index a14a81b..00dcacb 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeRebalanceStatusModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeRebalanceStatusModel.java
@@ -55,7 +55,6 @@
 
         };
         refresh.scheduleRepeating(10000);
-        this.entity = volumeEntity;
     }
 
     public ListModel getRebalanceSessions() {
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 d90d7fb..e334ab0 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
@@ -1557,6 +1557,9 @@
     @DefaultStringValue("Remove Bricks")
     String removeBricksTitle();
 
+    @DefaultStringValue("Remove Bricks Status")
+    String removeBricksStatusTitle();
+
     @DefaultStringValue("Replace Brick")
     String replaceBrickTitle();
 
@@ -1581,6 +1584,9 @@
     @DefaultStringValue("Are you sure you want to stop the removal operation 
of the following bricks?")
     String stopRemoveBricksMessage();
 
+    @DefaultStringValue("Stop")
+    String stopRemoveBricksButton();
+
     @DefaultStringValue("Commit Brick Removal")
     String commitRemoveBricksTitle();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
index 703199b..358ceea 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
@@ -2648,6 +2648,9 @@
     @DefaultStringValue("Commit")
     String removeBricksCommit();
 
+    @DefaultStringValue("Status")
+    String removeBricksStatus();
+
     @DefaultStringValue("Replace Brick")
     String replaceBrickBrick();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
index f5cb513..7a7ce84 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java
@@ -96,6 +96,7 @@
             final Provider<AddBrickPopupPresenterWidget> addBrickPopupProvider,
             final Provider<RemoveBrickPopupPresenterWidget> 
removeConfirmPopupProvider,
             final Provider<RemoveBrickPopupPresenterWidget> 
removeBrickPopupProvider,
+            final Provider<VolumeRebalanceStatusPopupPresenterWidget> 
removeBricksStatusPopupProvider,
             final Provider<ReplaceBrickPopupPresenterWidget> 
replaceBrickPopupProvider,
             final Provider<BrickAdvancedDetailsPopupPresenterWidget> 
brickDetailsPopupProvider) {
         return new SearchableDetailTabModelProvider<GlusterBrickEntity, 
VolumeListModel, VolumeBrickListModel>(
@@ -110,6 +111,8 @@
                     return addBrickPopupProvider.get();
                 } else if (lastExecutedCommand == 
getModel().getRemoveBricksCommand()) {
                     return removeBrickPopupProvider.get();
+                } else if (lastExecutedCommand == 
getModel().getStatusRemoveBricksCommand()) {
+                    return removeBricksStatusPopupProvider.get();
                 } else if (lastExecutedCommand == 
getModel().getReplaceBrickCommand()) {
                     return replaceBrickPopupProvider.get();
                 } else if (lastExecutedCommand == 
getModel().getBrickAdvancedDetailsCommand()) {
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java
index 72cca63..832cd65 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java
@@ -174,6 +174,8 @@
                 return value.getAsyncTask() != null && 
value.getAsyncTask().getType() == GlusterTaskType.REMOVE_BRICK;
             }
         };
+        menuCell.addMenuItem(constants.removeBricksStatus(), 
getMainModel().getBrickListModel()
+                .getStatusRemoveBricksCommand());
         menuCell.addMenuItem(constants.removeBricksStop(), 
getMainModel().getBrickListModel()
                 .getStopRemoveBricksCommand());
         menuCell.addMenuItem(constants.removeBricksCommit(), 
getMainModel().getBrickListModel()
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeBrickView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeBrickView.java
index 9dd8fef..373bc81 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeBrickView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/gluster/SubTabVolumeBrickView.java
@@ -130,6 +130,7 @@
                 return value.getAsyncTask().getType() == 
GlusterTaskType.REMOVE_BRICK;
             }
         };
+        menuCell.addMenuItem(constants.removeBricksStatus(), 
getDetailModel().getStatusRemoveBricksCommand());
         menuCell.addMenuItem(constants.removeBricksStop(), 
getDetailModel().getStopRemoveBricksCommand());
         menuCell.addMenuItem(constants.removeBricksCommit(), 
getDetailModel().getCommitRemoveBricksCommand());
         return menuCell;


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

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

Reply via email to