summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java3
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java8
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationWorkbenchAdvisor.java5
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java10
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java11
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java111
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeOptionsPage.java8
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java10
8 files changed, 107 insertions, 59 deletions
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java
index b87d38f5..b6384a18 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java
@@ -35,4 +35,7 @@ public class GlusterConstants {
public static final String FSTYPE_EXT_3 = "ext3";
public static final String FSTYPE_EXT_4 = "ext4";
public static final String FSTYPE_XFS = "xfs";
+
+ public static final String ON = "on";
+ public static final String OFF = "off";
}
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java
index 250d05c3..9255414c 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java
@@ -33,6 +33,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
+import com.gluster.storage.management.core.constants.GlusterConstants;
import com.gluster.storage.management.core.utils.GlusterCoreUtil;
import com.gluster.storage.management.core.utils.StringUtil;
@@ -59,6 +60,7 @@ public class Volume extends Entity {
public static final int DEFAULT_STRIPE_COUNT = 4;
public static final String OPTION_AUTH_ALLOW = "auth.allow";
+ public static final String OPTION_NFS_DISABLE = "nfs.disable";
private static final String[] VOLUME_TYPE_STR = new String[] { "Plain Distribute", "Distributed Mirror",
"Distributed Stripe" };
@@ -77,9 +79,9 @@ public class Volume extends Entity {
public Volume() {
}
- // GlusterFS and NFS export is always enabled
+ // Only GlusterFS is enabled
private Set<NAS_PROTOCOL> nasProtocols = new LinkedHashSet<NAS_PROTOCOL>(Arrays.asList(new NAS_PROTOCOL[] {
- NAS_PROTOCOL.GLUSTERFS, NAS_PROTOCOL.NFS }));
+ NAS_PROTOCOL.GLUSTERFS }));
public String getVolumeTypeStr() {
return getVolumeTypeStr(getVolumeType());
@@ -234,10 +236,12 @@ public class Volume extends Entity {
public void enableNFS() {
nasProtocols.add(NAS_PROTOCOL.NFS);
+ setOption(OPTION_NFS_DISABLE, GlusterConstants.OFF);
}
public void disableNFS() {
nasProtocols.remove(NAS_PROTOCOL.NFS);
+ setOption(OPTION_NFS_DISABLE, GlusterConstants.ON);
}
public Volume(String name, Entity parent, VOLUME_TYPE volumeType, TRANSPORT_TYPE transportType, VOLUME_STATUS status) {
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();
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java
index 22da9ca3..b7112c08 100644
--- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java
+++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.gluster.storage.management.core.constants.CoreConstants;
+import com.gluster.storage.management.core.constants.GlusterConstants;
import com.gluster.storage.management.core.exceptions.GlusterRuntimeException;
import com.gluster.storage.management.core.model.Brick;
import com.gluster.storage.management.core.model.Brick.BRICK_STATUS;
@@ -447,6 +448,15 @@ public class GlusterUtil {
if (line.matches("^[^:]*:.*$")) {
int index = line.indexOf(':');
volume.setOption(line.substring(0, index).trim(), line.substring(index + 1, line.length()).trim());
+
+ if (line.substring(0, index).trim().equals(Volume.OPTION_NFS_DISABLE)) {
+ if (line.substring(index + 1, line.length()).trim().equals(GlusterConstants.ON)) {
+ volume.disableNFS();
+ } else {
+ volume.enableNFS();
+ }
+ }
+
return true;
}
return false;