Kanagaraj M has uploaded a new change for review.

Change subject: webadmin: [WIP] adding stop rebalance action
......................................................................

webadmin: [WIP] adding stop rebalance action

Added a new sub-action 'Stop' under the 'Rebalance' action group.
'Stop' rebalance action will be enabled if the Volume status is UP
and a rebalance operation is already going on.

On clicking 'Stop' rebalance, a confirmation window will be show
to confirming the stop rebalance operation.

Change-Id: I6afc4b3ae9dbea60713178da51700b3197c38bfe
Signed-off-by: Kanagaraj M <kmayi...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.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/section/main/view/tab/MainTabVolumeView.java
3 files changed, 102 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/18541/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java
index bac681d..2ed624f 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java
@@ -20,6 +20,7 @@
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType;
 import org.ovirt.engine.core.common.businessentities.gluster.TransportType;
 import org.ovirt.engine.core.common.interfaces.SearchType;
+import org.ovirt.engine.core.common.job.JobExecutionStatus;
 import org.ovirt.engine.core.common.mode.ApplicationMode;
 import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.core.common.queries.GetConfigurationValueParameters;
@@ -85,6 +86,7 @@
     private UICommand startCommand;
     private UICommand stopCommand;
     private UICommand startRebalanceCommand;
+    private UICommand stopRebalanceCommand;
     private UICommand optimizeForVirtStoreCommand;
 
     public UICommand getStartRebalanceCommand() {
@@ -93,6 +95,14 @@
 
     public void setStartRebalanceCommand(UICommand startRebalanceCommand) {
         this.startRebalanceCommand = startRebalanceCommand;
+    }
+
+    public UICommand getStopRebalanceCommand() {
+        return stopRebalanceCommand;
+    }
+
+    public void setStopRebalanceCommand(UICommand stopRebalanceCommand) {
+        this.stopRebalanceCommand = stopRebalanceCommand;
     }
 
     public UICommand getStartCommand() {
@@ -132,12 +142,14 @@
         setStartCommand(new UICommand("Start", this)); //$NON-NLS-1$
         setStopCommand(new UICommand("Stop", this)); //$NON-NLS-1$
         setStartRebalanceCommand(new UICommand("StartRebalance", this)); 
//$NON-NLS-1$
+        setStopRebalanceCommand(new UICommand("StopRebalace", this)); 
//$NON-NLS-1$
         setOptimizeForVirtStoreCommand(new UICommand("OptimizeForVirtStore", 
this)); //$NON-NLS-1$
 
         getRemoveVolumeCommand().setIsExecutionAllowed(false);
         getStartCommand().setIsExecutionAllowed(false);
         getStopCommand().setIsExecutionAllowed(false);
         getStartRebalanceCommand().setIsExecutionAllowed(false);
+        getStopRebalanceCommand().setIsExecutionAllowed(false);
 
         getSearchNextPageCommand().setIsAvailable(true);
         getSearchPreviousPageCommand().setIsAvailable(true);
@@ -336,6 +348,7 @@
         boolean allowStop = true;
         boolean allowRemove = true;
         boolean allowStartRebalance = true;
+        boolean allowStopRebalance = true;
         boolean allowOptimize = true;
 
         if (getSelectedItems() == null || getSelectedItems().size() == 0) {
@@ -343,6 +356,7 @@
             allowStop = false;
             allowRemove = false;
             allowStartRebalance = false;
+            allowStopRebalance = false;
             allowOptimize = false;
         }
         else {
@@ -354,9 +368,13 @@
                 else if (volume.getStatus() == GlusterStatus.DOWN) {
                     allowStop = false;
                     allowStartRebalance = false;
+                    allowStopRebalance = false;
                 }
                 allowStartRebalance = allowStartRebalance &&
                         (volume.getAsyncTask() == null || 
Guid.isNullOrEmpty(volume.getAsyncTask().getTaskId()));
+                allowStopRebalance = allowStopRebalance &&
+                        (volume.getAsyncTask() != null && 
volume.getAsyncTask().getStatus() != null &&
+                        volume.getAsyncTask().getStatus() == 
JobExecutionStatus.STARTED);
             }
         }
 
@@ -364,6 +382,7 @@
         getStopCommand().setIsExecutionAllowed(allowStop);
         getRemoveVolumeCommand().setIsExecutionAllowed(allowRemove);
         getStartRebalanceCommand().setIsExecutionAllowed(allowStartRebalance);
+        getStopRebalanceCommand().setIsExecutionAllowed(allowStopRebalance);
         getOptimizeForVirtStoreCommand().setIsExecutionAllowed(allowOptimize);
 
         // System tree dependent actions.
@@ -397,6 +416,10 @@
             stop();
         } else if (command.equals(getStartRebalanceCommand())) {
             startRebalance();
+        } else if (command.equals(getStopRebalanceCommand())) {
+            stopRebalance();
+        } else if (command.getName().equals("onStopRebalance")) { //$NON-NLS-1$
+            onStopRebalance();
         } else if (command.equals(getOptimizeForVirtStoreCommand())) {
             optimizeForVirtStore();
         } else if (command.getName().equals("onStop")) {//$NON-NLS-1$
@@ -421,6 +444,72 @@
         Frontend.RunMultipleAction(VdcActionType.StartRebalanceGlusterVolume, 
list);
     }
 
+    private void stopRebalance() {
+        if (getWindow() != null) {
+            return;
+        }
+
+        if (getSelectedItems() == null) {
+            return;
+        }
+
+        ConfirmationModel model = new ConfirmationModel();
+        setWindow(model);
+        
model.setTitle(ConstantsManager.getInstance().getConstants().confirmStopVolumeRebalanceTitle());
+        model.setHashName("volume_rebalance_stop"); //$NON-NLS-1$
+        
model.setMessage(ConstantsManager.getInstance().getConstants().confirmStopVolumeRebalanceMsg());
+
+        ArrayList<String> list = new ArrayList<String>();
+        for (Object item : getSelectedItems()) {
+            GlusterVolumeEntity volume = (GlusterVolumeEntity) item;
+            list.add(volume.getName());
+        }
+        model.setItems(list);
+
+        UICommand okCommand = new UICommand("onStopRebalance", this); 
//$NON-NLS-1$
+        okCommand.setTitle(ConstantsManager.getInstance().getConstants().ok());
+        okCommand.setIsDefault(true);
+        model.getCommands().add(okCommand);
+        UICommand cancelCommand = new UICommand("Cancel", this); //$NON-NLS-1$
+        
cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel());
+        cancelCommand.setIsCancel(true);
+        model.getCommands().add(cancelCommand);
+    }
+
+    private void onStopRebalance() {
+        if (getWindow() == null) {
+            return;
+        }
+        ConfirmationModel model = (ConfirmationModel) getWindow();
+
+        if (model.getProgress() != null) {
+            return;
+        }
+
+        if (getSelectedItems() == null) {
+            return;
+        }
+
+        ArrayList<VdcActionParametersBase> list = new 
ArrayList<VdcActionParametersBase>();
+        for (Object item : getSelectedItems()) {
+            GlusterVolumeEntity volume = (GlusterVolumeEntity) item;
+            list.add(new GlusterVolumeRebalanceParameters(volume.getId(), 
false, false));
+        }
+
+        model.startProgress(null);
+
+        Frontend.RunMultipleAction(VdcActionType.StopRebalanceGlusterVolume, 
list,
+                new IFrontendMultipleActionAsyncCallback() {
+                    @Override
+                    public void executed(FrontendMultipleActionAsyncResult 
result) {
+                        ConfirmationModel localModel = (ConfirmationModel) 
result.getState();
+                        localModel.stopProgress();
+                        cancel();
+                    }
+
+                }, model);
+    }
+
     private void optimizeForVirtStore() {
         if (getSelectedItems() == null || getSelectedItems().size() == 0) {
             return;
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 1612ebd..45eab16 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
@@ -1594,6 +1594,12 @@
     @DefaultStringValue("Multiple bricks of a Replicate volume are present on 
the same server. This setup is not optimal. \nDo you still want to continue?")
     String addBricksToReplicateVolumeFromSameServerMsg();
 
+    @DefaultStringValue("Stop Rebalance")
+    String confirmStopVolumeRebalanceTitle();
+
+    @DefaultStringValue("Are you sure you want to stop the rebalance operation 
in following Volume(s)?")
+    String confirmStopVolumeRebalanceMsg();
+
     @DefaultStringValue("Disable Gluster Hooks")
     String confirmDisableGlusterHooks();
 
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 1d489c2..4ed73a3 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
@@ -160,6 +160,13 @@
             }
         });
 
+        rebalanceSubActions.add(new 
WebAdminButtonDefinition<GlusterVolumeEntity>(constants.stopRebalance()) {
+            @Override
+            protected UICommand resolveCommand() {
+                return getMainModel().getStopRebalanceCommand();
+            }
+        });
+
         getTable().addActionButton(new 
WebAdminMenuBarButtonDefinition<GlusterVolumeEntity>(constants.rebalanceVolume(),rebalanceSubActions,CommandLocation.ContextAndToolBar));
     }
 }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6afc4b3ae9dbea60713178da51700b3197c38bfe
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