diff options
| author | Selvasundaram <selvam@gluster.com> | 2011-08-22 18:03:22 +0530 |
|---|---|---|
| committer | Selvasundaram <selvam@gluster.com> | 2011-08-22 18:03:22 +0530 |
| commit | 46c9fb4c80af9de7db7d933e37e612b2bb1776fe (patch) | |
| tree | ef5201e7f5ca1c6875f92c23e20b3f3e4ff545f7 /src | |
| parent | ef8a0962ce2069b0c6082e33f2b08ae8b1738820 (diff) | |
confirmation dialog added for CIFS configuration during create, start, stop and delete volume activities
Diffstat (limited to 'src')
6 files changed, 108 insertions, 6 deletions
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterDataModelManager.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterDataModelManager.java index 82a24209..83986745 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterDataModelManager.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterDataModelManager.java @@ -969,4 +969,24 @@ public class GlusterDataModelManager { } return volumeNames; } + + public List<String> getOfflineServers() { + List<String> offlineServers = new ArrayList<String>(); + for(GlusterServer server : model.getCluster().getServers()) { + if (!server.isOnline()) { + offlineServers.add(server.getName()); + } + } + return offlineServers; + } + + public List<String> getCifsEnabledVolumeNames(List<Volume> selectedVolumes) { + List<String> cifsVolumes = new ArrayList<String>(); + for(Volume volume : selectedVolumes) { + if (volume.isCifsEnable()) { + cifsVolumes.add(volume.getName()); + } + } + return cifsVolumes; + } } diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java index 869e37e3..2befda7d 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java @@ -47,6 +47,21 @@ public class DeleteVolumeAction extends AbstractMonitoredActionDelegate { collectVolumeNames(); String warningMessage; + List<String> cifsVolumes = GlusterDataModelManager.getInstance().getCifsEnabledVolumeNames(selectedVolumes); + List<String> offlineServers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (cifsVolumes != null && cifsVolumes.size() > 0 && offlineServers != null && offlineServers.size() > 0) { + Integer userAction = new MessageDialog(getShell(), "CIFS configuration", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, + new String[] { "No", "Yes" }, -1).open(); + if (userAction != 1) { + return; // Do not delete volume services + } + } + if (onlineVolumeNames.size() > 0) { // Getting confirmation for stop and delete warningMessage = "Following volume(s) " + onlineVolumeNames + " are online, " + CoreConstants.NEWLINE + "Are you sure to continue?" + CoreConstants.NEWLINE + selectedVolumeNames; @@ -54,13 +69,13 @@ public class DeleteVolumeAction extends AbstractMonitoredActionDelegate { warningMessage = "Are you sure to delete the volumes " + selectedVolumeNames + " ?"; } - final Integer directoryDeleteOption = new MessageDialog(getShell(), "Delete Volume", GUIHelper.getInstance().getImage( - IImageKeys.VOLUME_16x16), warningMessage, MessageDialog.QUESTION, new String[] { "Cancel", + final Integer directoryDeleteOption = new MessageDialog(getShell(), "Delete Volume", GUIHelper.getInstance() + .getImage(IImageKeys.VOLUME_16x16), warningMessage, MessageDialog.QUESTION, new String[] { "Cancel", "Delete volume and data", "Delete volume, keep data" }, -1).open(); if (directoryDeleteOption <= 0) { // By Cancel button(0) or Escape key(-1) return; } - + VolumesClient vc = new VolumesClient(); boolean confirmDeleteDir = (directoryDeleteOption == 1) ? true : false; List<String> deletedVolumeNames = new ArrayList<String>(); diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java index 8b2b3f09..03cdc4e8 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java @@ -24,10 +24,12 @@ import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import com.gluster.storage.management.client.VolumesClient; import com.gluster.storage.management.console.GlusterDataModelManager; +import com.gluster.storage.management.console.IImageKeys; import com.gluster.storage.management.console.utils.GUIHelper; import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.model.Volume; @@ -56,7 +58,21 @@ public class StartVolumeAction extends AbstractMonitoredActionDelegate { List<String> startedVolumes = new ArrayList<String>(); List<String> failedVolumes = new ArrayList<String>(); String errorMessage = ""; - + List<String> cifsVolumes = GlusterDataModelManager.getInstance().getCifsEnabledVolumeNames(selectedVolumes); + List<String> offlineServers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (cifsVolumes != null && cifsVolumes.size() > 0 && offlineServers != null && offlineServers.size() > 0) { + Integer userAction = new MessageDialog(getShell(), "CIFS configuration", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, + new String[] { "No", "Yes" }, -1).open(); + if (userAction != 1) { + return; // Do not start volume services + } + } + monitor.beginTask("Starting Selected Volumes...", selectedVolumes.size()); for (Volume volume : selectedVolumes.toArray(new Volume[0])) { if(monitor.isCanceled()) { diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java index bda0e661..aa2a0c7c 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java @@ -65,7 +65,21 @@ public class StopVolumeAction extends AbstractMonitoredActionDelegate { List<String> stoppedVolumes = new ArrayList<String>(); List<String> failedVolumes = new ArrayList<String>(); String errorMessage = ""; - + List<String> cifsVolumes = GlusterDataModelManager.getInstance().getCifsEnabledVolumeNames(selectedVolumes); + List<String> offlineServers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (cifsVolumes != null && cifsVolumes.size() > 0 && offlineServers != null && offlineServers.size() > 0) { + userAction = new MessageDialog(getShell(), "CIFS configuration", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, + new String[] { "No", "Yes" }, -1).open(); + if (userAction != 1) { + return; // Do not stop volume services + } + } + Volume newVolume = new Volume(); monitor.beginTask("Stopping Selected Volumes...", selectedVolumes.size()); diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java index 498723d9..87f8ccd4 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java @@ -18,14 +18,18 @@ *******************************************************************************/ package com.gluster.storage.management.console.dialogs; +import java.util.List; + import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.wizard.Wizard; import com.gluster.storage.management.client.VolumesClient; import com.gluster.storage.management.console.GlusterDataModelManager; +import com.gluster.storage.management.console.IImageKeys; import com.gluster.storage.management.console.utils.GUIHelper; import com.gluster.storage.management.console.utils.GlusterLogger; import com.gluster.storage.management.core.constants.CoreConstants; +import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; @@ -51,6 +55,20 @@ public class CreateVolumeWizard extends Wizard { VolumesClient volumesClient = new VolumesClient(); try { + List<String> servers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (newVolume.isCifsEnable() && servers != null && servers.size() > 0) { + Integer userAction = new MessageDialog(getShell(), "Create Volume", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, new String[] { "No", + "Yes" }, -1).open(); + if (userAction != 1) { + return false; // To stay on the create dialog + } + } + volumesClient.createVolume(newVolume); // Set proper volume type before assign to model diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java index dafc6c80..e271623d 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java @@ -39,6 +39,7 @@ import com.gluster.storage.management.console.GlusterDataModelManager; import com.gluster.storage.management.console.IImageKeys; import com.gluster.storage.management.console.toolbar.GlusterToolbarManager; import com.gluster.storage.management.console.utils.GUIHelper; +import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.model.Alert; import com.gluster.storage.management.core.model.Brick; @@ -420,15 +421,29 @@ public class VolumeSummaryView extends ViewPart { public void run() { VolumesClient vc = new VolumesClient(); Volume newVolume = new Volume(); + Integer userAction = 1; String cifsUsers = cifsUsersText.getText().trim(); + List<String> servers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (servers != null && servers.size() > 0) { + userAction = new MessageDialog(parent.getShell(), "CIFS configuration", GUIHelper + .getInstance().getImage(IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + + CoreConstants.NEWLINE + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, new String[] { + "No", "Yes" }, -1).open(); + } + // If no cifs users and removing cifs config, nothing to do if (!(!cifsCheckbox.getSelection() && volume.getCifsUsers().toString() == "[]" && (cifsUsers - .isEmpty() || cifsUsers.equals("")))) { + .isEmpty() || cifsUsers.equals(""))) && userAction == 1) { try { vc.setCifsConfig(volume.getName(), cifsCheckbox.getSelection(), cifsUsers); enableCifsUsersControls(false); newVolume = vc.getVolume(volume.getName()); modelManager.volumeChanged(volume, newVolume); + showCifsUsersControls(volume.isCifsEnable()); } catch (Exception e) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Cifs Configuration", e.getMessage()); @@ -436,6 +451,10 @@ public class VolumeSummaryView extends ViewPart { enableCifsUsersControls(cifsCheckbox.getSelection()); populateCifsUsersText(); } + } else { + newVolume = vc.getVolume(volume.getName()); + modelManager.volumeChanged(volume, newVolume); + showCifsUsersControls(volume.isCifsEnable()); } } }); |
