diff options
| author | Dhandapani <dhandapani@gluster.com> | 2011-07-25 14:58:10 +0530 |
|---|---|---|
| committer | Dhandapani <dhandapani@gluster.com> | 2011-07-25 21:57:27 +0530 |
| commit | 483500a2f159e29a9304a659c327b6be56f44cd3 (patch) | |
| tree | 3066315a0cbcbab8dea691037cd0efb6a30f2681 /src/com.gluster.storage.management.gui | |
| parent | a2a52d53ee2e0dd32b993c112200cfd1c927aafa (diff) | |
NFS volume Enable/Disable feature
Diffstat (limited to 'src/com.gluster.storage.management.gui')
5 files changed, 88 insertions, 57 deletions
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchAdvisor.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchAdvisor.java index 73a10b01..1d381055 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchAdvisor.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchAdvisor.java @@ -74,4 +74,9 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { } }); } + + @Override + public boolean preShutdown() { + return syncJob.cancel(); + } } diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java index 14086260..3a6c72a4 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java @@ -32,15 +32,15 @@ import com.gluster.storage.management.client.DiscoveredServersClient; import com.gluster.storage.management.client.GlusterServersClient; import com.gluster.storage.management.client.TasksClient; import com.gluster.storage.management.client.VolumesClient; +import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.Alert; import com.gluster.storage.management.core.model.Alert.ALERT_TYPES; import com.gluster.storage.management.core.model.Brick; +import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; import com.gluster.storage.management.core.model.Cluster; import com.gluster.storage.management.core.model.ClusterListener; import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Alert.ALERT_TYPES; -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; import com.gluster.storage.management.core.model.Device.DEVICE_STATUS; import com.gluster.storage.management.core.model.Disk; import com.gluster.storage.management.core.model.Event; @@ -817,7 +817,11 @@ public class GlusterDataModelManager { public void setAccessControlList(Volume volume, String accessControlList) { setVolumeOption(volume, Volume.OPTION_AUTH_ALLOW, accessControlList); } - + + public void setNfsEnabled(Volume volume, boolean enabled) { + setVolumeOption(volume, Volume.OPTION_NFS_DISABLE, (enabled) ? GlusterConstants.OFF : GlusterConstants.ON); + } + public Server getGlusterServer(String serverName) { for (Server server : model.getCluster().getServers()) { if (server.getName().equals(serverName)) { diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java index 26cb0c2f..96da6fa3 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java @@ -330,9 +330,16 @@ public class CreateVolumePage1 extends WizardPage { nasProtocols.add(NAS_PROTOCOL.NFS); volume.setAccessControlList(txtAccessControl.getText()); + + if (btnNfs.getSelection()) { + volume.enableNFS(); + } else { + volume.disableNFS(); + } - for(Device device : selectedDevices) { - Brick brick = new Brick(device.getServerName(), BRICK_STATUS.ONLINE, device.getName(), device.getMountPoint() + File.separator + volume.getName()); + for (Device device : selectedDevices) { + Brick brick = new Brick(device.getServerName(), BRICK_STATUS.ONLINE, device.getName(), + device.getMountPoint() + File.separator + volume.getName()); volume.addBrick(brick); } diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java index 8b5b3fee..e5ed937e 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java @@ -12,6 +12,8 @@ import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.FillLayout; @@ -32,6 +34,7 @@ import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.part.ViewPart; import com.gluster.storage.management.client.VolumesClient; +import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.model.Alert; import com.gluster.storage.management.core.model.Brick; import com.gluster.storage.management.core.model.Cluster; @@ -42,7 +45,6 @@ import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.Partition; import com.gluster.storage.management.core.model.Server.SERVER_STATUS; import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.NAS_PROTOCOL; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; import com.gluster.storage.management.core.utils.NumberUtil; import com.gluster.storage.management.core.utils.StringUtil; @@ -67,6 +69,11 @@ public class VolumeSummaryView extends ViewPart { private Composite parent; private static final String COURIER_FONT = "Courier"; private Cluster cluster = GlusterDataModelManager.getInstance().getModel().getCluster(); + private Button nfsCheckBox; + private FormText glusterNfsMountText; + private String nfsMountInfo; + private Label nfsLabel; + private String nfs; @Override public void createPartControl(Composite parent) { @@ -85,6 +92,9 @@ public class VolumeSummaryView extends ViewPart { public void volumeChanged(Volume volume, Event event) { updateVolumeStatusLabel(); populateAccessControlText(); + Boolean isNFSExported = (volume.getOptions().getOption(Volume.OPTION_NFS_DISABLE).getValue() + .equals(GlusterConstants.OFF) ? true : false); + changeNFSStatus(isNFSExported); toolbarManager.updateToolbar(volume); } }; @@ -134,12 +144,12 @@ public class VolumeSummaryView extends ViewPart { private void createVolumeMountingInfoSection() { String glusterFs = "Gluster:"; - String nfs = "NFS:"; + nfs = "NFS:"; String onlineServers = getOnlineServers(10); // Limited to 10 servers String firstOnlineServer = onlineServers.split(",")[0].trim(); String glusterFsMountInfo = "mount -t glusterfs " + firstOnlineServer + ":/" + volume.getName() + " <mount-point>"; - String nfsMountInfo = "mount -t nfs " + firstOnlineServer + ":/" + volume.getName() + " <mount-point>"; + nfsMountInfo = "mount -t nfs " + firstOnlineServer + ":/" + volume.getName() + " <mount-point>"; String info = "Server can be any server name in the storage cloud eg. <" + onlineServers + ">"; // TODO: if more // than 10 // servers... @@ -153,14 +163,18 @@ public class VolumeSummaryView extends ViewPart { glusterfsMountText.setLayoutData(new GridData(GridData.BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, false, 2, 0)); // Label spanned two column - // TODO: Check required if nfs is optional - toolkit.createLabel(section, nfs, SWT.NORMAL); - FormText glusterNfsMountText = setFormTextStyle(toolkit.createFormText(section, true), COURIER_FONT, 10, - SWT.NONE); + nfsLabel = toolkit.createLabel(section, nfs, SWT.NONE); + GridData data = new GridData(); + data.horizontalAlignment = SWT.FILL; + nfsLabel.setLayoutData(data); + + glusterNfsMountText = setFormTextStyle(toolkit.createFormText(section, true), COURIER_FONT, 10, SWT.NONE); glusterNfsMountText.setText(nfsMountInfo, false, false); glusterNfsMountText.setLayoutData(new GridData(GridData.BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, false, 2, 0)); + changeNFSStatus( nfsCheckBox.getSelection()); + toolkit.createLabel(section, ""); Label infoLabel = toolkit.createLabel(section, info, SWT.NONE); infoLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, false, 2, 0)); @@ -238,7 +252,7 @@ public class VolumeSummaryView extends ViewPart { accessControlText = toolkit.createText(section, volume.getAccessControlList()); populateAccessControlText(); - addKeyListerForAccessControl(); + addKeyListenerForAccessControl(); accessControlText.setLayoutData(createDefaultLayoutData()); accessControlText.setEnabled(false); createChangeLinkForAccessControl(section); @@ -315,8 +329,31 @@ public class VolumeSummaryView extends ViewPart { guiHelper.clearStatusMessage(); parent.update(); } + + private void saveNFSOption() { + guiHelper.setStatusMessage("Setting NFS option..."); + parent.update(); + + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + @Override + public void run() { + try { + boolean enableNfs = nfsCheckBox.getSelection(); + new VolumesClient().setVolumeOption(volume.getName(), Volume.OPTION_NFS_DISABLE, + (enableNfs) ? GlusterConstants.OFF : GlusterConstants.ON); + GlusterDataModelManager.getInstance().setNfsEnabled(volume, enableNfs); + } catch (Exception e) { + MessageDialog.openError(Display.getDefault().getActiveShell(), "NFS Option", e.getMessage()); + } + } + }); - private void addKeyListerForAccessControl() { + GlusterDataModelManager.getInstance().addClusterListener(volumeChangedListener); + guiHelper.clearStatusMessage(); + parent.update(); + } + + private void addKeyListenerForAccessControl() { accessControlText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent key) { switch (key.keyCode) { @@ -354,52 +391,36 @@ public class VolumeSummaryView extends ViewPart { nasProtocolsComposite.setLayout(new FillLayout()); createCheckbox(nasProtocolsComposite, "Gluster", true, false); - final Button nfsCheckBox = createCheckbox(nasProtocolsComposite, "NFS", - volume.getNASProtocols().contains(NAS_PROTOCOL.NFS), true); + + boolean isNFSEnabled = (volume.getOptions().getOption(Volume.OPTION_NFS_DISABLE).getValue() + .equalsIgnoreCase(GlusterConstants.ON)) ? false : true; + + nfsCheckBox = createCheckbox(nasProtocolsComposite, "NFS", isNFSEnabled, true); + + nfsCheckBox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + saveNFSOption(); + } + }); + + // CIFS checkbox createCheckbox(nasProtocolsComposite, "CIFS", false, true); toolkit.createLabel(section, "", SWT.NONE); // dummy // createChangeLinkForNASProtocol(section, nfsCheckBox); } - private Button createCheckbox(Composite parent, String label, boolean selected, boolean enabled) { + private Button createCheckbox(Composite parent, String label, boolean checked, boolean enabled) { final Button checkBox = toolkit.createButton(parent, label, SWT.CHECK); + checkBox.setSelection(checked); checkBox.setEnabled(enabled); - checkBox.setSelection(selected); return checkBox; } - - private void createChangeLinkForNASProtocol(Composite section, final Button nfsCheckBox) { - final Hyperlink nasChangeLink = toolkit.createHyperlink(section, "change", SWT.NONE); - nasChangeLink.addHyperlinkListener(new HyperlinkAdapter() { - - private void finishEdit() { - // TODO: Update value to back-end - if (nfsCheckBox.getSelection()) { - volume.enableNFS(); - } else { - volume.disableNFS(); - } - nfsCheckBox.setEnabled(false); - nasChangeLink.setText("change"); - } - - private void startEdit() { - nfsCheckBox.setEnabled(true); - nasChangeLink.setText("update"); - } - - @Override - public void linkActivated(HyperlinkEvent e) { - if (nfsCheckBox.isEnabled()) { - // we were already in edit mode. - finishEdit(); - } else { - // Get in to edit mode - startEdit(); - } - } - }); + + private void changeNFSStatus(Boolean isNFSExported) { + glusterNfsMountText.setVisible(isNFSExported); + nfsLabel.setVisible(isNFSExported); } private double getDiskSize(String serverName, String deviceName) { diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeOptionsPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeOptionsPage.java index 1331a81f..69434e96 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeOptionsPage.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeOptionsPage.java @@ -157,13 +157,7 @@ public class VolumeOptionsPage extends Composite { setAddButtonsEnabled(false); } - if (tableViewer.getTable().getItemCount() < volume.getOptions().size()) { - // new volume set from outside this page. refresh the viewer. - tableViewer.refresh(); - } else { - // existing volume option value changed. update that element. - tableViewer.update(volume.getOptions().get(key), null); - } + tableViewer.refresh(); break; case VOLUME_CHANGED: tableViewer.refresh(); |
