diff options
| author | Dhandapani <dhandapani@gluster.com> | 2011-08-01 11:20:36 +0530 |
|---|---|---|
| committer | Dhandapani <dhandapani@gluster.com> | 2011-08-02 17:24:22 +0530 |
| commit | 397232596f760b9bbe6aa2ed02fc4161fced13c0 (patch) | |
| tree | 1457ea64aa804275d4f2740dcc5b332c5e0d17e1 /src | |
| parent | 5e89ccaac396f3ff780fea8558b72ea3a29c5030 (diff) | |
Story #56: CIFS Feature
Diffstat (limited to 'src')
38 files changed, 504 insertions, 88 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/ClustersClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/ClustersClient.java index 0185084c..d6bf962a 100644 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/ClustersClient.java +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/ClustersClient.java @@ -24,8 +24,6 @@ import static com.gluster.storage.management.core.constants.RESTConstants.RESOUR import java.util.List; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.response.ClusterNameListResponse; import com.sun.jersey.api.representation.Form; diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/DiscoveredServersClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/DiscoveredServersClient.java index c85cdffd..e1b8f234 100644 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/DiscoveredServersClient.java +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/DiscoveredServersClient.java @@ -25,9 +25,7 @@ import java.util.List; import javax.ws.rs.core.MultivaluedMap; -import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.response.GenericResponse; import com.gluster.storage.management.core.response.ServerListResponse; import com.gluster.storage.management.core.response.ServerNameListResponse; import com.gluster.storage.management.core.utils.GlusterCoreUtil; diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java index 3bc22370..85c7d383 100644 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java @@ -28,9 +28,7 @@ import javax.ws.rs.core.MultivaluedMap; import com.gluster.storage.management.core.constants.RESTConstants; import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server; import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.model.ServerStatsRow; import com.gluster.storage.management.core.response.GlusterServerListResponse; import com.gluster.storage.management.core.utils.GlusterCoreUtil; import com.sun.jersey.api.representation.Form; diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java index 3435b2e1..fb254d26 100644 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java @@ -22,6 +22,8 @@ package com.gluster.storage.management.client; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_ACCESS_PROTOCOLS; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_BRICKS; +import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_ENABLE; +import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_USERS; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_REPLICA_COUNT; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_STRIPE_COUNT; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_TRANSPORT_TYPE; @@ -40,7 +42,6 @@ import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.constants.RESTConstants; import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.TaskInfo; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.VolumeLogMessage; import com.gluster.storage.management.core.model.VolumeOptionInfo; @@ -81,6 +82,7 @@ public class VolumesClient extends AbstractClient { form.add(FORM_PARAM_BRICKS, StringUtil.collectionToString(volume.getBricks(), ",")); form.add(FORM_PARAM_ACCESS_PROTOCOLS, StringUtil.collectionToString(volume.getNASProtocols(), ",")); form.add(FORM_PARAM_VOLUME_OPTIONS, StringUtil.collectionToString(volume.getOptions().getOptions(), ",")); + form.add(FORM_PARAM_CIFS_USERS, StringUtil.collectionToString(volume.getCifsUsers(), ",")); postRequest(form); } @@ -99,6 +101,14 @@ public class VolumesClient extends AbstractClient { performOperation(volumeName, RESTConstants.TASK_STOP); } + public void setCifsConfig(String volumeName, Boolean isCifsEnabled, String cifsUsers) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_CIFS_CONFIG); + form.add(RESTConstants.FORM_PARAM_CIFS_ENABLE, isCifsEnabled); + form.add(RESTConstants.FORM_PARAM_CIFS_USERS, cifsUsers); + putRequest(volumeName, form); + } + public boolean volumeExists(String volumeName) { try { // TODO: instead of fetching full volume name, fetch list of volumes and check if diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java index 699346f7..f562a53c 100644 --- a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java +++ b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java @@ -25,11 +25,9 @@ import static org.junit.Assert.assertTrue; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; -import java.io.InputStream; import java.io.OutputStreamWriter; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java index edf3bbe4..45cf5980 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java @@ -54,6 +54,7 @@ public class RESTConstants { public static final String TASK_REBALANCE_START = "rebalanceStart"; public static final String TASK_REBALANCE_STATUS = "rebalanceStatus"; public static final String TASK_REBALANCE_STOP = "rebalanceStop"; + public static final String TASK_CIFS_CONFIG = "cifsConfig"; public static final String FORM_PARAM_VOLUME_NAME = "name"; public static final String FORM_PARAM_VOLUME_TYPE = "volumeType"; @@ -64,6 +65,8 @@ public class RESTConstants { public static final String FORM_PARAM_ACCESS_PROTOCOLS = "accessProtocols"; public static final String FORM_PARAM_VOLUME_OPTIONS = "options"; public static final String FORM_PARAM_FSTYPE = "fsType"; + public static final String FORM_PARAM_CIFS_ENABLE = "enableCifs"; + public static final String FORM_PARAM_CIFS_USERS = "cifsUsers"; public static final String FORM_PARAM_CLUSTER_NAME = "clusterName"; public static final String FORM_PARAM_SERVER_NAME = "serverName"; diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java index 92943074..9c7ac80b 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java @@ -19,7 +19,6 @@ package com.gluster.storage.management.core.model; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; import com.gluster.storage.management.core.utils.StringUtil; diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java index 701fe426..fc824db2 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java @@ -20,6 +20,7 @@ package com.gluster.storage.management.core.model; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; + import com.gluster.storage.management.core.utils.ProcessResult; @XmlRootElement(name = "status") 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 0cb6e972..2c3bd2ba 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 @@ -52,7 +52,7 @@ public class Volume extends Entity { }; public enum NAS_PROTOCOL { - GLUSTERFS, NFS + GLUSTERFS, NFS, CIFS }; @@ -66,7 +66,7 @@ public class Volume extends Entity { "Distributed Stripe" }; private static final String[] TRANSPORT_TYPE_STR = new String[] { "Ethernet", "Infiniband" }; private static final String[] STATUS_STR = new String[] { "Online", "Offline" }; - private static final String[] NAS_PROTOCOL_STR = new String[] { "Gluster", "NFS" }; + private static final String[] NAS_PROTOCOL_STR = new String[] { "Gluster", "NFS", "CIFS" }; private VOLUME_TYPE volumeType; private TRANSPORT_TYPE transportType; @@ -75,6 +75,7 @@ public class Volume extends Entity { private int stripeCount; private VolumeOptions options = new VolumeOptions(); private List<Brick> bricks = new ArrayList<Brick>(); + private List<String> cifsUsers; public Volume() { } @@ -253,6 +254,31 @@ public class Volume extends Entity { nasProtocols.remove(NAS_PROTOCOL.NFS); setOption(OPTION_NFS_DISABLE, GlusterConstants.ON); } + + public void enableCifs() { + nasProtocols.add(NAS_PROTOCOL.CIFS); + } + + public void disableCifs() { + nasProtocols.remove(NAS_PROTOCOL.CIFS); + } + + public boolean isCifsEnable() { + if (nasProtocols.contains(NAS_PROTOCOL.CIFS)) { + return true; + } else { + return false; + } + } + + public void setCifsUsers(List<String> cifsUsers) { + this.cifsUsers = cifsUsers; + } + + public List<String> getCifsUsers() { + return cifsUsers; + } + public Volume(String name, Entity parent, VOLUME_TYPE volumeType, TRANSPORT_TYPE transportType, VOLUME_STATUS status) { super(name, parent); diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java index 4040a4e7..edeec768 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java @@ -19,15 +19,10 @@ package com.gluster.storage.management.core.model; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; /** * diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerListResponse.java index f375905c..868e2fc2 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerListResponse.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerListResponse.java @@ -24,12 +24,9 @@ import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Status; /** * diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java index a0d90634..601a3790 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java @@ -20,10 +20,8 @@ package com.gluster.storage.management.core.utils; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; -import java.io.InputStream; import java.util.UUID; import com.gluster.storage.management.core.constants.CoreConstants; diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java index c021aeb2..6b06e900 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java @@ -23,6 +23,8 @@ package com.gluster.storage.management.gateway.resources.v1_0; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_ACCESS_PROTOCOLS; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_AUTO_COMMIT; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_BRICKS; +import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_ENABLE; +import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_USERS; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FIX_LAYOUT; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FORCED_DATA_MIGRATE; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_MIGRATE_DATA; @@ -59,6 +61,8 @@ import static com.gluster.storage.management.core.constants.RESTConstants.TASK_S import static com.gluster.storage.management.core.constants.RESTConstants.TASK_STOP; import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -89,6 +93,7 @@ import com.gluster.storage.management.core.model.Brick; import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.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.model.VolumeLogMessage; import com.gluster.storage.management.core.response.GenericResponse; @@ -97,6 +102,7 @@ import com.gluster.storage.management.core.response.VolumeListResponse; import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; import com.gluster.storage.management.core.utils.DateUtil; import com.gluster.storage.management.core.utils.FileUtil; +import com.gluster.storage.management.core.utils.ProcessResult; import com.gluster.storage.management.core.utils.ProcessUtil; import com.gluster.storage.management.gateway.constants.VolumeOptionsDefaults; import com.gluster.storage.management.gateway.data.ClusterInfo; @@ -112,6 +118,15 @@ import com.sun.jersey.spi.resource.Singleton; @Path(RESOURCE_PATH_CLUSTERS + "/{" + PATH_PARAM_CLUSTER_NAME + "}/" + RESOURCE_VOLUMES) public class VolumesResource extends AbstractResource { private static final String VOLUME_DIRECTORY_CLEANUP_SCRIPT = "clear_volume_directory.py"; + + private static final String VOLUME_CIFS_GRUN_SCRIPT = "grun.py"; + private static final String VOLUME_CREATE_CIFS_SCRIPT = "create_volume_cifs.py"; + private static final String VOLUME_START_CIFS_SCRIPT = "start_volume_cifs.py"; + private static final String VOLUME_STOP_CIFS_SCRIPT = "stop_volume_cifs.py"; + private static final String VOLUME_DELETE_CIFS_SCRIPT = "delete_volume_cifs.py"; + private static final String VOLUME_MODIFY_CIFS_SCRIPT = "modify_volume_cifs.py"; + private static final String ALL_SERVERS_FILE_NAME = "servers"; + private static final String VOLUME_BRICK_LOG_SCRIPT = "get_volume_brick_log.py"; private static final Logger logger = Logger.getLogger(VolumesResource.class); @@ -130,6 +145,8 @@ public class VolumesResource extends AbstractResource { @InjectParam private TasksResource taskResource; + private ProcessUtil processUtil = new ProcessUtil(); + @GET @Produces({MediaType.APPLICATION_XML}) public Response getVolumesXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) { @@ -185,13 +202,14 @@ public class VolumesResource extends AbstractResource { @FormParam(FORM_PARAM_VOLUME_TYPE) String volumeType, @FormParam(FORM_PARAM_TRANSPORT_TYPE) String transportType, @FormParam(FORM_PARAM_REPLICA_COUNT) Integer replicaCount, @FormParam(FORM_PARAM_STRIPE_COUNT) Integer stripeCount, @FormParam(FORM_PARAM_BRICKS) String bricks, @FormParam(FORM_PARAM_ACCESS_PROTOCOLS) String accessProtocols, - @FormParam(FORM_PARAM_VOLUME_OPTIONS) String options) { + @FormParam(FORM_PARAM_VOLUME_OPTIONS) String options, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers) { if(clusterName == null || clusterName.isEmpty()) { return badRequestResponse("Cluster name must not be empty!"); } - String missingParam = checkMissingParamsForCreateVolume(volumeName, volumeType, transportType, replicaCount, stripeCount, bricks, accessProtocols, options); - if(missingParam != null) { + String missingParam = checkMissingParamsForCreateVolume(volumeName, volumeType, transportType, replicaCount, + stripeCount, bricks, accessProtocols, options); + if (missingParam != null) { return badRequestResponse("Parameter [" + missingParam + "] is missing in request!"); } @@ -209,7 +227,7 @@ public class VolumesResource extends AbstractResource { try { performCreateVolume(clusterName, volumeName, volumeType, transportType, replicaCount, stripeCount, bricks, accessProtocols, - options); + options, cifsUsers); return createdResponse(volumeName); } catch (Exception e) { return errorResponse(e.getMessage()); @@ -217,25 +235,37 @@ public class VolumesResource extends AbstractResource { } public void performCreateVolume(String clusterName, String volumeName, String volumeType, String transportType, Integer replicaCount, - Integer stripeCount, String bricks, String accessProtocols, String options) { + Integer stripeCount, String bricks, String accessProtocols, String options, String cifsUsers) { GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); if (onlineServer == null) { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } try { - glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, replicaCount, stripeCount, bricks, accessProtocols, options); + glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, replicaCount, + stripeCount, bricks, accessProtocols, options); } catch (ConnectionException e) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); if (onlineServer == null) { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } - - glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, replicaCount, stripeCount, bricks, accessProtocols, options); + + glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, replicaCount, + stripeCount, bricks, accessProtocols, options); + } + + List<String> nasProtocols = Arrays.asList(accessProtocols.split(",")); + // only if cifs enabled + if (nasProtocols.contains(NAS_PROTOCOL.CIFS.toString())) { + try { + createCIFSUsers(clusterName, volumeName, Arrays.asList(cifsUsers.split(","))); + } catch (Exception e) { + throw new GlusterRuntimeException(CoreConstants.NEWLINE + e.getMessage()); + } } } - + /** * Returns name of the missing parameter if any. If all parameters are present, * @param volumeName @@ -325,7 +355,8 @@ public class VolumesResource extends AbstractResource { @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_OPERATION) String operation, @FormParam(FORM_PARAM_FIX_LAYOUT) Boolean isFixLayout, @FormParam(FORM_PARAM_MIGRATE_DATA) Boolean isMigrateData, - @FormParam(FORM_PARAM_FORCED_DATA_MIGRATE) Boolean isForcedDataMigrate) { + @FormParam(FORM_PARAM_FORCED_DATA_MIGRATE) Boolean isForcedDataMigrate, + @FormParam(FORM_PARAM_CIFS_ENABLE) Boolean enableCifs, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers) { if (clusterName == null || clusterName.isEmpty()) { return badRequestResponse("Cluster name must not be empty!"); } @@ -345,6 +376,12 @@ public class VolumesResource extends AbstractResource { + "/" + taskId); } else if (operation.equals(RESTConstants.TASK_REBALANCE_STOP)) { rebalanceStop(clusterName, volumeName); + } else if (operation.equals(RESTConstants.TASK_CIFS_CONFIG)) { + if (enableCifs) { + modifyCIFSUsers(clusterName, volumeName, Arrays.asList(cifsUsers.split(","))); + } else { + stopCifsReexport(clusterName, volumeName); + } } else { performVolumeOperation(clusterName, volumeName, operation); } @@ -361,23 +398,151 @@ public class VolumesResource extends AbstractResource { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } - performOperation(volumeName, operation, onlineServer); + performOperation(clusterName, volumeName, operation, onlineServer); } catch (ConnectionException e) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); - performOperation(volumeName, operation, onlineServer); + performOperation(clusterName, volumeName, operation, onlineServer); } } - private void performOperation(String volumeName, String operation, GlusterServer onlineServer) { + private Status performOperation(String clusterName, String volumeName, String operation, GlusterServer onlineServer) { + Status result; + Volume volume = null; + try { + volume = getVolume(clusterName, volumeName); + } catch (Exception e) { + throw new GlusterRuntimeException("Could not fetch volume info for volume [" + volumeName + "]" + + e.getMessage()); + } + if (operation.equals(TASK_START)) { - glusterUtil.startVolume(volumeName, onlineServer.getName()); + result = glusterUtil.startVolume(volumeName, onlineServer.getName()); + + // call the start_volume_cifs.py script only if the volume is cifs enabled + if (volume.getNASProtocols().contains(NAS_PROTOCOL.CIFS)) { + if (result.isSuccess()) { + startCifsReexport(onlineServer.getName(), volumeName); + } + } + return result; } else if (operation.equals(TASK_STOP)) { - glusterUtil.stopVolume(volumeName, onlineServer.getName()); + result = glusterUtil.stopVolume(volumeName, onlineServer.getName()); + + // call the stop_volume_cifs.py script only if the volume is cifs enabled + if (volume.getNASProtocols().contains(NAS_PROTOCOL.CIFS)) { + if (result.isSuccess()) { + stopCifsReexport(onlineServer.getName(), volumeName); + } + } + return result; } else { throw new GlusterValidationException("Invalid operation code [" + operation + "]"); } } + + private void startCifsReexport(String clusterName, String volumeName) { + File file; + try { + file = createOnlineServerList(clusterName); + } catch (IOException e) { + throw new GlusterRuntimeException("Error in CIFS configuration after stop volume [" + volumeName + "]: " + e.getMessage()); + } + + ProcessResult result = processUtil.executeCommand(VOLUME_CIFS_GRUN_SCRIPT + " " + file.getAbsolutePath() + " " + + VOLUME_START_CIFS_SCRIPT + " " + volumeName); + file.delete(); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Error in cifs configuration after start volume [" + volumeName + "]: " + + result); + } + } + + private void stopCifsReexport(String clusterName, String volumeName) { + File file; + try { + file = createOnlineServerList(clusterName); + } catch (IOException e) { + throw new GlusterRuntimeException("Error in CIFS configuration after stop volume [" + volumeName + "]: " + e.getMessage()); + } + + ProcessResult result = processUtil.executeCommand(VOLUME_CIFS_GRUN_SCRIPT + " " + file.getAbsolutePath() + " " + + VOLUME_STOP_CIFS_SCRIPT + " " + volumeName); + file.delete(); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Error in cifs configuration after stop volume [" + volumeName + "]: " + + result); + } + } + + private void deleteCifsUsers(String clusterName, String volumeName) { + File file; + try { + file = createOnlineServerList(clusterName); + } catch (IOException e) { + throw new GlusterRuntimeException("Error in deleting CIFS configuration [" + volumeName + "]: " + e.getMessage()); + } + + ProcessResult result = processUtil.executeCommand(VOLUME_CIFS_GRUN_SCRIPT + " " + file.getAbsolutePath() + " " + + VOLUME_DELETE_CIFS_SCRIPT + " " + volumeName); + file.delete(); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Error in cifs configuration after delete volume [" + volumeName + "]: " + + result); + } + } + + private void createCIFSUsers(String clusterName, String volumeName, List<String> cifsUsers) { + File file; + try { + file = createOnlineServerList(clusterName); + } catch (IOException e) { + throw new GlusterRuntimeException("Error in CIFS configuration [" + volumeName + "]: " + e.getMessage()); + } + String users = ""; + for (String user : cifsUsers) { + users += " " + user; + } + ProcessResult result = processUtil.executeCommand(VOLUME_CIFS_GRUN_SCRIPT + " " + file.getAbsolutePath() + " " + + VOLUME_CREATE_CIFS_SCRIPT + " " + volumeName + users); + file.delete(); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Error in CIFS configuration [" + volumeName + "]: " + result); + } + } + + private void modifyCIFSUsers(String clusterName, String volumeName, List<String> cifsUsers) { + File file; + try { + file = createOnlineServerList(clusterName); + } catch (IOException e) { + throw new GlusterRuntimeException("Error in CIFS configuration [" + volumeName + "]: " + e.getMessage()); + } + String users = ""; + for (String user : cifsUsers) { + users += " " + user; + } + ProcessResult result = processUtil.executeCommand(VOLUME_CIFS_GRUN_SCRIPT + " " + file.getAbsolutePath() + " " + + VOLUME_MODIFY_CIFS_SCRIPT + " " + volumeName + users); + file.delete(); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Error in CIFS configuration [" + volumeName + "]: " + result); + } + } + + public File createOnlineServerList(String clusterName) throws IOException { + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + String clusterServersListFile = FileUtil.getTempDirName() + CoreConstants.FILE_SEPARATOR + ALL_SERVERS_FILE_NAME; + List<GlusterServer> glusterServers = glusterUtil.getGlusterServers(onlineServer); + File serversFile = new File(clusterServersListFile); + FileOutputStream fos = new FileOutputStream(serversFile); + for (GlusterServer server : glusterServers) { + fos.write((server.getName() + CoreConstants.NEWLINE).getBytes()); + } + fos.close(); + return serversFile; + + } @DELETE @Path("{" + PATH_PARAM_VOLUME_NAME + "}") @@ -423,6 +588,15 @@ public class VolumesResource extends AbstractResource { + e.getMessage()); } + // call the delete_volume_cifs.py script only if the volume is cifs enabled + if (volume.getNASProtocols().contains(NAS_PROTOCOL.CIFS)) { + try { + deleteCifsUsers(clusterName, volumeName); + } catch (Exception e) { + return errorResponse(CoreConstants.NEWLINE + e.getMessage()); + } + } + return noContentResponse(); } diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationActionBarAdvisor.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationActionBarAdvisor.java index 8b5dba55..56e5247c 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationActionBarAdvisor.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/ApplicationActionBarAdvisor.java @@ -18,7 +18,6 @@ *******************************************************************************/ package com.gluster.storage.management.gui; -import org.eclipse.jface.action.Action; import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.ICoolBarManager; import org.eclipse.jface.action.IMenuManager; 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 bc262e7e..27485fb6 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 @@ -18,7 +18,6 @@ *******************************************************************************/ package com.gluster.storage.management.gui; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; 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 d301ad10..1b3d6e55 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 @@ -844,6 +844,15 @@ public class GlusterDataModelManager { setVolumeOption(volume, Volume.OPTION_NFS_DISABLE, (enabled) ? GlusterConstants.OFF : GlusterConstants.ON); } + public void setCifsConfig(Volume volume, boolean enabled, List<String> cifsUsers) { + if (enabled) { + volume.enableCifs(); + volume.setCifsUsers(cifsUsers); + } else { + volume.disableCifs(); + } + } + 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/TasksTableLabelProvider.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/TasksTableLabelProvider.java index 4c3544ee..cbe5ed08 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/TasksTableLabelProvider.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/TasksTableLabelProvider.java @@ -24,8 +24,6 @@ import org.eclipse.swt.graphics.Image; import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.gui.DeviceTableLabelProvider.DEVICE_COLUMN_INDICES; import com.gluster.storage.management.gui.utils.GUIHelper; import com.gluster.storage.management.gui.views.pages.TasksPage.TASK_TABLE_COLUMN_INDICES; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java index 70cb4757..d3427696 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/CreateVolumeAction.java @@ -20,14 +20,10 @@ package com.gluster.storage.management.gui.actions; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.gui.dialogs.CreateVolumeWizard; public class CreateVolumeAction extends AbstractActionDelegate { @@ -46,7 +42,7 @@ public class CreateVolumeAction extends AbstractActionDelegate { } }; dialog.create(); - dialog.getShell().setSize(500, 585); + dialog.getShell().setSize(500, 610); dialog.open(); } diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/PauseTaskAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/PauseTaskAction.java index a9dceaa3..3cb8c608 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/PauseTaskAction.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/PauseTaskAction.java @@ -28,7 +28,6 @@ import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskInfo; import com.gluster.storage.management.core.model.TaskStatus; import com.gluster.storage.management.gui.GlusterDataModelManager; -import com.gluster.storage.management.gui.toolbar.GlusterToolbarManager; public class PauseTaskAction extends AbstractActionDelegate { diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/TestPopupMenuAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/TestPopupMenuAction.java index e1fe0f14..d98f58f5 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/TestPopupMenuAction.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/TestPopupMenuAction.java @@ -22,6 +22,7 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionDelegate; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddBrickPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddBrickPage.java index 14e36852..e570c068 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddBrickPage.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddBrickPage.java @@ -31,7 +31,6 @@ import org.eclipse.swt.widgets.Composite; import com.gluster.storage.management.core.model.Brick; import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Disk; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; import com.gluster.storage.management.gui.GlusterDataModelManager; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddBrickWizard.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddBrickWizard.java index 0270eddb..ec632ee3 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddBrickWizard.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddBrickWizard.java @@ -21,7 +21,6 @@ package com.gluster.storage.management.gui.dialogs; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.eclipse.jface.dialogs.MessageDialog; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/ClusterSelectionDialog.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/ClusterSelectionDialog.java index f5d2f6dd..2a9266e8 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/ClusterSelectionDialog.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/ClusterSelectionDialog.java @@ -20,8 +20,6 @@ package com.gluster.storage.management.gui.dialogs; import java.util.List; -import org.eclipse.core.runtime.preferences.ConfigurationScope; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.fieldassist.ControlDecoration; @@ -43,13 +41,8 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.osgi.service.prefs.BackingStoreException; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.gui.Activator; -import com.gluster.storage.management.gui.Application; -import com.gluster.storage.management.gui.IImageKeys; import com.gluster.storage.management.gui.preferences.PreferenceConstants; import com.gluster.storage.management.gui.utils.GUIHelper; 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 96da6fa3..a491b1ba 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 @@ -20,6 +20,7 @@ package com.gluster.storage.management.gui.dialogs; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -35,6 +36,8 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -48,10 +51,10 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Text; 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.Device; import com.gluster.storage.management.core.model.Disk; import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; import com.gluster.storage.management.core.model.Volume.NAS_PROTOCOL; import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; @@ -63,6 +66,7 @@ public class CreateVolumePage1 extends WizardPage { private Text txtName; private ComboViewer typeComboViewer; private Text txtAccessControl; + private Text txtCifsUsers; private Volume volume = new Volume(); private Button btnNfs; private Button btnCIFS; @@ -120,6 +124,9 @@ public class CreateVolumePage1 extends WizardPage { createCifsUserLabel(container); createCifsUserText(container); + createEmptyLabel(container); + createCifsUserInfoLabel(container); + createAccessControlLabel(container); createAccessControlText(container); @@ -140,6 +147,12 @@ public class CreateVolumePage1 extends WizardPage { lblStartVolume.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblStartVolume.setText("Start Volume: "); } + + private void createCifsUserInfoLabel(Composite container) { + Label lblCifsUserInfo = new Label(container, SWT.TOP); + lblCifsUserInfo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblCifsUserInfo.setText("(Comma separated list user names)"); + } private void createAccessControlInfoLabel(Composite container) { Label lblAccessControlInfo = new Label(container, SWT.TOP); @@ -178,11 +191,18 @@ public class CreateVolumePage1 extends WizardPage { } private void createCifsUserText(Composite container) { - txtAccessControl = new Text(container, SWT.BORDER); - txtAccessControl.setText("testuser1,testuser2,testuser3"); - GridData accessControlData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - accessControlData.widthHint = 300; - txtAccessControl.setLayoutData(accessControlData); + txtCifsUsers = new Text(container, SWT.BORDER); +// txtCifsUsers.setText("testuser1,testuser2,testuser3"); + GridData cifsControlData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + cifsControlData.widthHint = 300; + txtCifsUsers.setLayoutData(cifsControlData); + txtCifsUsers.addModifyListener(new ModifyListener() { + + @Override + public void modifyText(ModifyEvent e) { + validateForm(); + } + }); } private void createNasProtocolCheckboxes(Composite container) { @@ -202,6 +222,17 @@ public class CreateVolumePage1 extends WizardPage { btnCIFS.setEnabled(true); btnCIFS.setSelection(true); btnCIFS.setText("CIFS"); + btnCIFS.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + validateForm(); + } + @Override + public void widgetDefaultSelected(SelectionEvent e) { + validateForm(); + } + }); } private void createNasProtocolLabel(Composite container) { @@ -337,6 +368,13 @@ public class CreateVolumePage1 extends WizardPage { volume.disableNFS(); } + if (btnCIFS.getSelection()) { + volume.enableCifs(); + volume.setCifsUsers(Arrays.asList(txtCifsUsers.getText().split(","))); + } else { + volume.disableCifs(); + } + for (Device device : selectedDevices) { Brick brick = new Brick(device.getServerName(), BRICK_STATUS.ONLINE, device.getName(), device.getMountPoint() + File.separator + volume.getName()); @@ -364,6 +402,7 @@ public class CreateVolumePage1 extends WizardPage { private void validateForm() { clearErrors(); validateVolumeName(); + validateCifsUsers(); validateAccessControl(); validateDisks(); } @@ -395,6 +434,16 @@ public class CreateVolumePage1 extends WizardPage { setError("Access control list must be a comma separated list of IP addresses/Host names. Please enter a valid value!"); } } + + private void validateCifsUsers() { + if (btnCIFS.getSelection()) { + String cifsUserList = txtCifsUsers.getText().trim(); + if (cifsUserList.length() == 0) { + setError("Please enter cifs user name"); + return; + } + } + } private void validateVolumeName() { String volumeName = txtName.getText().trim(); diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/LoginDialog.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/LoginDialog.java index 401bdce0..11f0ac87 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/LoginDialog.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/LoginDialog.java @@ -45,7 +45,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; import com.gluster.storage.management.client.ClustersClient; import com.gluster.storage.management.client.UsersClient; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateBrickPage1.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateBrickPage1.java index 015978e6..69836284 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateBrickPage1.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/MigrateBrickPage1.java @@ -45,7 +45,6 @@ import org.eclipse.swt.widgets.Text; import com.gluster.storage.management.core.model.Brick; import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Disk; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.utils.NumberUtil; import com.gluster.storage.management.gui.GlusterDataModelManager; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/GlusterPreferencePage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/GlusterPreferencePage.java index d7aa4162..d8eee3e4 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/GlusterPreferencePage.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/GlusterPreferencePage.java @@ -18,14 +18,12 @@ *******************************************************************************/ package com.gluster.storage.management.gui.preferences; -import java.awt.TextField; import java.util.List; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.ComboFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/ChartUtil.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/ChartUtil.java index b9e388c5..e2035468 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/ChartUtil.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/ChartUtil.java @@ -35,14 +35,12 @@ import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Hyperlink; -import com.gluster.storage.management.client.GlusterServersClient; import com.gluster.storage.management.core.constants.GlusterConstants; import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.NetworkInterface; import com.gluster.storage.management.core.model.ServerStats; import com.gluster.storage.management.core.model.ServerStatsRow; import com.gluster.storage.management.gui.Activator; -import com.gluster.storage.management.gui.GlusterDataModelManager; import com.gluster.storage.management.gui.preferences.PreferenceConstants; import com.ibm.icu.util.Calendar; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GlusterLogger.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GlusterLogger.java index 1d9b7d2f..29ce8922 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GlusterLogger.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GlusterLogger.java @@ -19,7 +19,6 @@ package com.gluster.storage.management.gui.utils; import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import com.gluster.storage.management.gui.Activator; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java index 3a2ff7e3..45893d12 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java @@ -22,7 +22,6 @@ package com.gluster.storage.management.gui.views; import java.util.List; -import org.eclipse.core.internal.resources.projectvariables.ParentVariableResolver; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.graphics.Image; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterViewsManager.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterViewsManager.java index ca8788e5..c30dfbc4 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterViewsManager.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterViewsManager.java @@ -29,7 +29,6 @@ import com.gluster.storage.management.core.model.Entity; import com.gluster.storage.management.core.model.EntityGroup; import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.TaskInfo; import com.gluster.storage.management.core.model.Volume; /** diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeBricksView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeBricksView.java index bb008f09..01930baa 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeBricksView.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeBricksView.java @@ -5,7 +5,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.part.ViewPart; import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.gui.GlusterDataModelManager; import com.gluster.storage.management.gui.utils.GUIHelper; import com.gluster.storage.management.gui.views.pages.BricksPage; 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 20439aca..0c421bd9 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 @@ -3,6 +3,7 @@ package com.gluster.storage.management.gui.views; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.eclipse.jface.dialogs.MessageDialog; @@ -44,7 +45,6 @@ import com.gluster.storage.management.core.model.Event; 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.TaskInfo; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; import com.gluster.storage.management.core.utils.NumberUtil; @@ -65,8 +65,11 @@ public class VolumeSummaryView extends ViewPart { private CLabel lblStatusValue; private DefaultClusterListener volumeChangedListener; private Hyperlink changeLink; + private Hyperlink CifsChangeLink; private Text accessControlText; + private Text cifsUsersText; private ControlDecoration errDecoration; + private ControlDecoration errCifsDecoration; private Composite parent; private static final String COURIER_FONT = "Courier"; private Cluster cluster = GlusterDataModelManager.getInstance().getModel().getCluster(); @@ -79,6 +82,9 @@ public class VolumeSummaryView extends ViewPart { private Label numberOfBricks; private Label totalDiskSpace; private Composite alertsSection; + private Button cifsCheckbox; + private Label cifsLabel; + private Composite cifsUpdateLinkComposite; @Override public void createPartControl(Composite parent) { @@ -251,6 +257,7 @@ public class VolumeSummaryView extends ViewPart { createDiskSpaceField(section); // createTransportTypeField(section); createNASProtocolField(section); + createCifsField(section); createAccessControlField(section); createStatusField(section); } @@ -261,10 +268,38 @@ public class VolumeSummaryView extends ViewPart { layoutData.widthHint = 300; return layoutData; } + + private void createCifsField(Composite section) { + GridData data = new GridData(); + data.heightHint = 0; + + cifsLabel = toolkit.createLabel(section, "CIFS: ", SWT.NONE); + cifsLabel.setLayoutData(data); + cifsLabel.setVisible(false); + + cifsUsersText = toolkit.createText(section, volume.getAccessControlList(), SWT.BORDER); + populateCifsUsersText(); + addKeyListenerForCifsUser(); + cifsUsersText.setLayoutData(createDefaultLayoutData()); + cifsUsersText.setEnabled(true); + cifsUsersText.setLayoutData(data); + cifsUsersText.setVisible(false); + + cifsUpdateLinkComposite = toolkit.createComposite(section, SWT.NONE); + cifsUpdateLinkComposite.setVisible(false); + cifsUpdateLinkComposite.setLayoutData(data); + cifsUpdateLinkComposite.setLayout(new FillLayout()); + + createChangeLinkForCifs(cifsUpdateLinkComposite); + + // error decoration used while validating the cifs users text + errCifsDecoration = guiHelper.createErrorDecoration(cifsUsersText); + errCifsDecoration.hide(); + } private void createAccessControlField(Composite section) { toolkit.createLabel(section, "Access Control: ", SWT.NONE); - accessControlText = toolkit.createText(section, volume.getAccessControlList()); + accessControlText = toolkit.createText(section, volume.getAccessControlList(), SWT.BORDER); populateAccessControlText(); addKeyListenerForAccessControl(); @@ -345,6 +380,75 @@ public class VolumeSummaryView extends ViewPart { parent.update(); } + private void createChangeLinkForCifs(Composite section) { + CifsChangeLink = toolkit.createHyperlink(section, "Update", SWT.NONE); + CifsChangeLink.addHyperlinkListener(new HyperlinkAdapter() { + + private void finishEdit() { + saveCifsConfiguration(); + } + + private void startEdit() { + cifsUsersText.setEnabled(true); + cifsUsersText.setFocus(); + cifsUsersText.selectAll(); + CifsChangeLink.setText("update"); + } + + @Override + public void linkActivated(HyperlinkEvent e) { + if (cifsUsersText.isEnabled()) { + // we were already in edit mode. + finishEdit(); + } else { + // Get in to edit mode + startEdit(); + } + } + }); + } + + private void saveCifsConfiguration() { + final String cifsUsers = cifsUsersText.getText(); + + guiHelper.setStatusMessage("Setting Cifs Configuration..."); + parent.update(); + + List<String> userList = volume.getCifsUsers(); + String configuredUsers = ""; + if (userList != null) { + configuredUsers = StringUtil.collectionToString(userList, ","); + } + + if (cifsUsersText.equals(configuredUsers)) { + cifsUsersText.setEnabled(false); + CifsChangeLink.setText("change"); + // There is no change in the users list + } else if(isvalidCifsUser()) { + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + @Override + public void run() { + try { + new VolumesClient().setCifsConfig(volume.getName(), cifsCheckbox.getSelection(), cifsUsers); + cifsUsersText.setEnabled(false); + CifsChangeLink.setText("change"); + + GlusterDataModelManager.getInstance().setCifsConfig(volume, cifsCheckbox.getSelection(), + Arrays.asList(cifsUsers.split(","))); + } catch (Exception e) { + MessageDialog.openError(Display.getDefault().getActiveShell(), "Cifs Configuration", e.getMessage()); + populateCifsUsersText(); + } + } + }); + } else { + MessageDialog.openError(Display.getDefault().getActiveShell(), "Cifs Configuration", "Please enter cifs user name "); + cifsUsersText.setFocus(); + } + guiHelper.clearStatusMessage(); + parent.update(); + } + private void saveNFSOption() { guiHelper.setStatusMessage("Setting NFS option..."); parent.update(); @@ -396,8 +500,36 @@ public class VolumeSummaryView extends ViewPart { } accessControlText.setText(accessControlList); } + + private void addKeyListenerForCifsUser() { + cifsUsersText.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent key) { + switch (key.keyCode) { + case SWT.ESC: + // Reset to default + populateCifsUsersText(); + break; + case 13: + // User has pressed enter. Save the new value + saveCifsConfiguration(); + break; + } + validateCifsUsers(); + } + }); + } + + private void populateCifsUsersText() { + List<String> userList = volume.getCifsUsers(); + if (userList == null) { + cifsUsersText.setText(""); + } else { + String users = StringUtil.collectionToString(userList, ","); + cifsUsersText.setText(users); + } + } - private void createNASProtocolField(Composite section) { + private void createNASProtocolField(final Composite section) { toolkit.createLabel(section, "Access Protocols: ", SWT.NONE); Composite nasProtocolsComposite = toolkit.createComposite(section); @@ -415,10 +547,53 @@ public class VolumeSummaryView extends ViewPart { }); // CIFS checkbox - createCheckbox(nasProtocolsComposite, "CIFS", false, true); - + cifsCheckbox = createCheckbox(nasProtocolsComposite, "CIFS", false, true); + cifsCheckboxListner(cifsCheckbox); + toolkit.createLabel(section, "", SWT.NONE); // dummy - // createChangeLinkForNASProtocol(section, nfsCheckBox); + } + + private void cifsCheckboxListner(final Button cifsCheckbox) { + cifsCheckbox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (cifsCheckbox.getSelection()) { + GridData data = new GridData(); + data.heightHint = 20; + data.widthHint = 100; + + cifsLabel.setVisible(true); + cifsLabel.setLayoutData(data); + + GridData data1 = new GridData(); + data1.heightHint = 20; + data1.widthHint = 300; + cifsUsersText.setVisible(true); + cifsUsersText.setLayoutData(data1); + + GridData data2 = new GridData(); + data2.heightHint = 25; + data2.widthHint = 75; + cifsUpdateLinkComposite.setVisible(true); + cifsUpdateLinkComposite.setLayoutData(data2); + form.reflow(true); + } else { + GridData data = new GridData(); + data.heightHint = 0; + + cifsUsersText.setVisible(false); + cifsUsersText.setLayoutData(data); + + cifsLabel.setVisible(false); + cifsLabel.setLayoutData(data); + + cifsUpdateLinkComposite.setVisible(false); + cifsUpdateLinkComposite.setLayoutData(data); + + form.reflow(true); + } + } + }); } private Button createCheckbox(Composite parent, String label, boolean checked, boolean enabled) { @@ -548,4 +723,28 @@ public class VolumeSummaryView extends ViewPart { errDecoration.show(); } } + + private void validateCifsUsers() { + if (cifsCheckbox.getSelection()) { + String cifsUserList = cifsUsersText.getText().trim(); + if (cifsUserList.length() == 0) { + errCifsDecoration.setDescriptionText("Please enter cifs user name"); + errCifsDecoration.show(); + } else { + errCifsDecoration.hide(); + } + } + } + + private boolean isvalidCifsUser() { + if (cifsCheckbox.getSelection()) { + String cifsUserList = cifsUsersText.getText().trim(); + if (cifsUserList.length() == 0) { + return false; + } else { + return true; + } + } + return true; + } } diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/AbstractDisksPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/AbstractDisksPage.java index b74dcd0e..571a75f5 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/AbstractDisksPage.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/AbstractDisksPage.java @@ -45,12 +45,11 @@ import com.gluster.storage.management.core.model.ClusterListener; import com.gluster.storage.management.core.model.DefaultClusterListener; import com.gluster.storage.management.core.model.Device; import com.gluster.storage.management.core.model.Device.DEVICE_STATUS; -import com.gluster.storage.management.core.model.Event.EVENT_TYPE; import com.gluster.storage.management.core.model.Disk; import com.gluster.storage.management.core.model.Entity; import com.gluster.storage.management.core.model.Event; +import com.gluster.storage.management.core.model.Event.EVENT_TYPE; import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Partition; import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.TaskInfo; import com.gluster.storage.management.gui.Application; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/AbstractTableViewerPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/AbstractTableViewerPage.java index a56350b9..7ac32ec2 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/AbstractTableViewerPage.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/AbstractTableViewerPage.java @@ -48,7 +48,6 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Hyperlink; import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.TaskInfo; import com.gluster.storage.management.gui.GlusterDataModelManager; import com.gluster.storage.management.gui.utils.GUIHelper; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/ServerLogsPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/ServerLogsPage.java index 0ff22e31..b64df430 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/ServerLogsPage.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/ServerLogsPage.java @@ -18,9 +18,6 @@ *******************************************************************************/ package com.gluster.storage.management.gui.views.pages; -import java.util.ArrayList; -import java.util.List; - import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.swt.SWT; diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/TasksPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/TasksPage.java index 106984da..2c87d1ea 100644 --- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/TasksPage.java +++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/TasksPage.java @@ -36,10 +36,7 @@ import org.eclipse.ui.IWorkbenchSite; import com.gluster.storage.management.core.model.ClusterListener; import com.gluster.storage.management.core.model.DefaultClusterListener; import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Event.EVENT_TYPE; import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.gui.TasksTableLabelProvider; import com.gluster.storage.management.gui.toolbar.GlusterToolbarManager; 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 d8b8387e..84a7ba6a 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 @@ -53,7 +53,6 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.model.DefaultClusterListener; import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Event.EVENT_TYPE; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.VolumeOption; import com.gluster.storage.management.core.model.VolumeOptionInfo; |
