diff options
Diffstat (limited to 'src/com.gluster.storage.management.core')
13 files changed, 377 insertions, 77 deletions
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 fb40be8a..47697eb9 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 @@ -34,4 +34,5 @@ public class RESTConstants { // Running tasks resource public static final String RESOURCE_PATH_RUNNING_TASKS = "/cluster/runningtasks"; + public static final String RESOURCE_PATH_ALERTS = "/cluster/alerts"; } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java new file mode 100644 index 00000000..947867c9 --- /dev/null +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java @@ -0,0 +1,51 @@ +package com.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "alert") +public class Alert { + public enum ALERT_TYPES { CPU_USAGE_ALERT, MEMORY_USAGE_ALERT, DISK_USAGE_ALERT, OFFLINE_VOLUME_DISKS_ALERT, OFFLINE_SERVERS_ALERT }; + + public static final String[] ALERT_TYPE_STR = {"High CPU Usage", "High Memory Usage", "Low Disk Space", "Offline Disks", "Offline Servers" }; + + protected String id; + protected ALERT_TYPES type; + protected String reference; + protected String message; + + public String getAlertType( ALERT_TYPES alertType) { + return ALERT_TYPE_STR[alertType.ordinal()]; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ALERT_TYPES getType() { + return type; + } + + public void setType(ALERT_TYPES type) { + this.type = type; + } + + public String getReference() { + return reference; + } + + public void setReference(String reference) { + this.reference = reference; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertListResponse.java new file mode 100644 index 00000000..bb3c754e --- /dev/null +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertListResponse.java @@ -0,0 +1,36 @@ +package com.gluster.storage.management.core.model; + +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; + +@XmlRootElement(name = "response") +public class AlertListResponse extends AbstractResponse { + private List<Alert> alerts = new ArrayList<Alert>(); + + public AlertListResponse() { + + } + + public AlertListResponse(List<Alert> alerts) { + setAlerts(alerts); + } + + public void setAlerts(List<Alert> alerts) { + this.alerts = alerts; + } + + @XmlElementWrapper(name = "alerts") + @XmlElement(name = "alert", type=Alert.class) + public List<Alert> getAlerts() { + return this.alerts; + } + + @Override + public Object getData() { + return getAlerts(); + } +} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertStatus.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertStatus.java new file mode 100644 index 00000000..8c563f49 --- /dev/null +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertStatus.java @@ -0,0 +1,13 @@ +package com.gluster.storage.management.core.model; + +public class AlertStatus { + protected String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java index 65d5ebea..1af57266 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java @@ -29,6 +29,7 @@ public class Cluster extends Entity { List<Server> discoveredServers = new ArrayList<Server>(); List<Volume> volumes = new ArrayList<Volume>(); List<RunningTask> runningTasks = new ArrayList<RunningTask>(); + List<Alert> alerts = new ArrayList<Alert>(); public Cluster() { } @@ -97,4 +98,16 @@ public class Cluster extends Entity { public void setRunningTasks(List<RunningTask> runningTasks) { this.runningTasks = runningTasks; } + + public List<Alert> getAlerts() { + return alerts; + } + + public void setAlerts(List<Alert> alerts) { + this.alerts = alerts; + } + + public void addAlert(Alert alert) { + this.alerts.add(alert); + } }
\ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java index 612cae31..733527c3 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java @@ -39,4 +39,8 @@ public class GlusterDataModel extends Entity { public void addCluster(Cluster cluster) { children.add(cluster); } + + public Cluster getCluster() { + return (Cluster) children.get(0); + } } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java index 11d31553..f25999f0 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java @@ -174,24 +174,24 @@ public class GlusterDummyModel { } private void addDisksToVolumes() { - volume1.addDisk(s1da); + volume1.addDisk("server1:sda"); - volume2.addDisk(s2da); - volume2.addDisk(s1db); - volume2.addDisk(s3da); - volume2.addDisk(s4da); + volume2.addDisk("server2:sda"); + volume2.addDisk("server1:sdb"); + volume2.addDisk("server3:sda"); + volume2.addDisk("server4:sda"); - volume3.addDisk(s2db); - volume3.addDisk(s4da); - volume3.addDisk(s5da); + volume3.addDisk("server2:sdb"); + volume3.addDisk("server4:sda"); + volume3.addDisk("server5:sda"); - volume4.addDisk(s1da); - volume4.addDisk(s3da); - volume4.addDisk(s4da); - volume4.addDisk(s5db); + volume4.addDisk("server1:sda"); + volume4.addDisk("server3:sda"); + volume4.addDisk("server4:sda"); + volume4.addDisk("server5:sdb"); - volume5.addDisk(s2da); - volume5.addDisk(s5db); + volume5.addDisk("server2:sda"); + volume5.addDisk("server5:sdb"); } private void initializeGlusterServers(Cluster cluster) { @@ -245,15 +245,35 @@ public class GlusterDummyModel { public static List<LogMessage> getDummyLogMessages() { return logMessages; } - + + public Disk getVolumeDisk(String volumeDisk) { + List<Disk> allDisks = getReadyDisksOfAllServers(); + String brickInfo[] = volumeDisk.split(":"); + for( Disk disk: allDisks) { + if (disk.getServerName() == brickInfo[0] && disk.getName() == brickInfo[1]) { + return disk; + } + } + return null; + } + public List<Disk> getReadyDisksOfVolume(Volume volume) { - List<Disk> disks = new ArrayList<Disk>(); - for (Disk disk : volume.getDisks()) { - if (disk.isReady()) { - disks.add(disk); +// List<Disk> disks = new ArrayList<Disk>(); +// for (Disk disk : volume.getDisks()) { +// if (disk.isReady()) { +// disks.add(disk); +// } +// } +// return disks; + Disk disk = null; + List<Disk> volumeDisks = new ArrayList<Disk>(); + for (String volumeDisk : volume.getDisks() ) { + disk = getVolumeDisk(volumeDisk); + if (disk != null && disk.isReady()) { + volumeDisks.add(disk); } } - return disks; + return volumeDisks; } public List<Disk> getReadyDisksOfAllVolumes() { diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java index 1a9d63f6..9787f1ee 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java @@ -22,17 +22,23 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class RunningTask { - + public enum TASK_TYPES { FORMAT_DISK, MIGRATE_DISK, VOLUME_REBALANCE }; + public String[] TASK_TYPE_STR = {"Formating Disk", "Migrating Disk", "Volume Rebalance"}; + protected String id; - protected String type; // FormatDisk, MigrateDisk, VolumeRebalance - protected Object reference; - protected String description; + protected TASK_TYPES type; // FormatDisk, MigrateDisk, VolumeRebalance + protected String reference; // Server: Server name, Volume: Volume name, Disk: disk name referred as "VolumeName:ServerName:DiskName" + protected String taskInfo; protected RunningTaskStatus status; // TODO redefine public RunningTask() { } + public String getTaskType(TASK_TYPES type) { + return TASK_TYPE_STR[type.ordinal()]; + } + public String getId() { return id; } @@ -41,28 +47,28 @@ public class RunningTask { this.id = id; } - public String getType() { + public TASK_TYPES getType() { return type; } - public void setType(String type) { + public void setType(TASK_TYPES type) { this.type = type; } - public Object getReference() { + public String getReference() { return reference; } - public void setReference(Object reference) { + public void setReference(String reference) { this.reference = reference; } - public String getDescription() { - return description; + public String getTaskInfo() { + return taskInfo; } - public void setDescription(String description) { - this.description = description; + public void setTaskInfo(String taskInfo) { + this.taskInfo = taskInfo; } public RunningTaskStatus getStatus() { 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 06d6efe1..c5fdb246 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 @@ -27,6 +27,8 @@ public class Status { public static final int STATUS_CODE_SUCCESS = 0; public static final int STATUS_CODE_FAILURE = 1; public static final int STATUS_CODE_RUNNING = 2; + public static final int STATUS_CODE_PAUSE = 3; + public static final int STATUS_CODE_WARNING = 4; public static final Status STATUS_SUCCESS = new Status(STATUS_CODE_SUCCESS, "Success"); public static final Status STATUS_FAILURE = new Status(STATUS_CODE_FAILURE, "Failure"); 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 a7e498c4..2322fa84 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 @@ -65,7 +65,7 @@ public class Volume extends Entity { private Map<String, String> options = new LinkedHashMap<String, String>(); private double totalDiskSpace = 0; - private List<Disk> disks = new ArrayList<Disk>(); + private List<String> disks = new ArrayList<String>(); public Volume() { } @@ -102,6 +102,17 @@ public class Volume extends Entity { public void setVolumeType(VOLUME_TYPE volumeType) { this.volumeType = volumeType; + // TODO find a way to get the replica / strip count + if (volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + setReplicaCount(0); + setStripeCount(3); + } else if(volumeType == VOLUME_TYPE.DISTRIBUTED_MIRROR) { + setReplicaCount(2); + setStripeCount(0); + } else{ + setReplicaCount(0); + setStripeCount(0); + } } public TRANSPORT_TYPE getTransportType() { @@ -186,26 +197,27 @@ public class Volume extends Entity { return totalDiskSpace; } - public List<Disk> getDisks() { + public List<String> getDisks() { return disks; } - public void addDisk(Disk disk) { - if (disks.add(disk) && disk.getStatus() != DISK_STATUS.OFFLINE) { - totalDiskSpace += disk.getSpace(); - } + public void addDisk(String disk) { +// if (disks.add(disk) && disk.getStatus() != DISK_STATUS.OFFLINE) { +// totalDiskSpace += disk.getSpace(); +// } + disks.add(disk); } - public void addDisks(List<Disk> disks) { - for (Disk disk : disks) { + public void addDisks(List<String> disks) { + for (String disk : disks) { addDisk(disk); } } - public void removeDisk(Disk disk) { - if (disks.remove(disk)) { - totalDiskSpace -= disk.getSpace(); - } + public void removeDisk(String disk) { +// if (disks.remove(disk)) { +// totalDiskSpace -= disk.getSpace(); +// } } public void removeAllDisks() { @@ -213,7 +225,7 @@ public class Volume extends Entity { totalDiskSpace = 0; } - public void setDisks(List<Disk> disks) { + public void setDisks(List<String> disks) { removeAllDisks(); addDisks(disks); } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeListResponse.java new file mode 100644 index 00000000..7ff98d22 --- /dev/null +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeListResponse.java @@ -0,0 +1,43 @@ +package com.gluster.storage.management.core.model; + +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; + +@XmlRootElement(name = "response") +public class VolumeListResponse extends AbstractResponse { + private List<Volume> volumes = new ArrayList<Volume>(); + + public VolumeListResponse() { + + } + + public VolumeListResponse(Status status, List<Volume> volumes) { + setStatus(status); + setVolumes(volumes); + } + + @XmlElementWrapper(name = "volumes") + @XmlElement(name = "volume", type = Volume.class) + public List<Volume> getVolumes() { + return this.volumes; + } + + /** + * @param volumes + * volumes to set + */ + public void setVolumes(List<Volume> volumes) { + this.volumes = volumes; + } + + @Override + @XmlTransient + public Object getData() { + return this.volumes; + } +} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java index ad5b4c2b..0e2b0b8d 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java @@ -30,6 +30,7 @@ import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.GlusterServer.SERVER_STATUS; import com.gluster.storage.management.core.model.Volume; import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; +import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; /** @@ -40,11 +41,21 @@ public class GlusterUtil { private static final String UUID_PFX = "Uuid:"; private static final String STATE_PFX = "State:"; private static final String GLUSTER_SERVER_STATUS_ONLINE = "Connected"; + + private static final String VOLUME_NAME_PFX = "Volume Name:"; + private static final String VOLUME_TYPE_PFX = "Type:"; + private static final String VOLUME_STATUS_PFX = "Status:"; + private static final String VOLUME_TRANSPORT_TYPE_PFX = "Transport-type:"; + private static final String VOLUME_BRICKS_GROUP_PFX = "Bricks"; // Colon not used + private static final String VOLUME_OPTIONS_RECONFIG_PFX = "Options Reconfigured"; + private static final String VOLUME_OPTIONS_AUTH_ALLOW = "auth.allow:"; + private static final ProcessUtil processUtil = new ProcessUtil(); /** - * Extract value of given token from given line. It is assumed that the token, if present, will be of the following - * form: <code>token: value</code> + * Extract value of given token from given line. It is assumed that the + * token, if present, will be of the following form: + * <code>token: value</code> * * @param line * Line to be analyzed @@ -74,11 +85,13 @@ public class GlusterUtil { // Host and UUID is found, we should look for state String state = extractToken(line, STATE_PFX); if (state != null) { - server.setStatus(state.contains(GLUSTER_SERVER_STATUS_ONLINE) ? SERVER_STATUS.ONLINE + server.setStatus(state + .contains(GLUSTER_SERVER_STATUS_ONLINE) ? SERVER_STATUS.ONLINE : SERVER_STATUS.OFFLINE); - // Completed populating current server. Add it to the list and reset all related variables. + // Completed populating current server. Add it to the list + // and reset all related variables. glusterServers.add(server); - + foundHost = false; foundUuid = false; server = null; @@ -107,11 +120,11 @@ public class GlusterUtil { } public List<String> getGlusterServerNames() { - String output = getPeerStatus(); - if(output == null) { + String output = getPeerStatus(); + if (output == null) { return null; } - + List<String> glusterServerNames = new ArrayList<String>(); for (String line : output.split(CoreConstants.NEWLINE)) { String hostName = extractToken(line, HOSTNAME_PFX); @@ -124,7 +137,8 @@ public class GlusterUtil { private String getPeerStatus() { String output; - ProcessResult result = processUtil.executeCommand("gluster", "peer", "status"); + ProcessResult result = processUtil.executeCommand("gluster", "peer", + "status"); if (!result.isSuccess()) { output = null; } @@ -133,55 +147,59 @@ public class GlusterUtil { } public ProcessResult addServer(String serverName) { - return processUtil.executeCommand("gluster", "peer", "probe", serverName); + return processUtil.executeCommand("gluster", "peer", "probe", + serverName); } - public ProcessResult startVolume(String volumeName) { - return processUtil.executeCommand("gluster", "volume", "start", volumeName); + return processUtil.executeCommand("gluster", "volume", "start", + volumeName); } public ProcessResult stopVolume(String volumeName) { - return processUtil.executeCommand("gluster", "--mode=script", "volume", "stop", volumeName); + return processUtil.executeCommand("gluster", "--mode=script", "volume", + "stop", volumeName); } public ProcessResult createVolume(Volume volume) { - int count=1; // replica or stripe count + int count = 1; // replica or stripe count String volumeType = null; - VOLUME_TYPE volType = volume.getVolumeType(); - if(volType == VOLUME_TYPE.DISTRIBUTED_MIRROR) { + VOLUME_TYPE volType = volume.getVolumeType(); + if (volType == VOLUME_TYPE.DISTRIBUTED_MIRROR) { volumeType = "replica"; count = 2; - } else if(volType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + } else if (volType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { volumeType = "stripe"; count = 4; } - + String transportTypeStr = null; TRANSPORT_TYPE transportType = volume.getTransportType(); - transportTypeStr = (transportType == TRANSPORT_TYPE.ETHERNET) ? "tcp" : "rdma"; - + transportTypeStr = (transportType == TRANSPORT_TYPE.ETHERNET) ? "tcp" + : "rdma"; + List<String> command = new ArrayList<String>(); command.add("gluster"); command.add("volume"); command.add("create"); command.add(volume.getName()); - if(volumeType != null) { + if (volumeType != null) { command.add(volumeType); command.add("" + count); } command.add("transport"); command.add(transportTypeStr); - for(Disk disk : volume.getDisks()) { - command.add(getBrickNotation(volume, disk)); + //TODO fix needed modified for error free code + for (String disk : volume.getDisks()) { + command.add(disk); } return processUtil.executeCommand(command); } - + public ProcessResult setOption(List<String> command) { return processUtil.executeCommand(command); } - + public ProcessResult setVolumeAccessControl(Volume volume) { List<String> command = new ArrayList<String>(); command.add("gluster"); @@ -192,27 +210,104 @@ public class GlusterUtil { command.add(volume.getAccessControlList()); return setOption(command); } - + /** * @param disk * @return */ private String getBrickNotation(Volume vol, Disk disk) { - // TODO: Figure out an appropriate directory INSIDE the DISK having given NAME (e.g. sda, sdb, etc) + // TODO: Figure out an appropriate directory INSIDE the DISK having + // given NAME (e.g. sda, sdb, etc) // String dirName = "/export/" + vol.getName() + "/" + disk.getName(); - + // if /export directory is not exist then create the directory boolean exists = (new File("/export")).exists(); - + if (!exists) { processUtil.executeCommand("mkdir", "/export"); } - String dirName = "/export/" + vol.getName() ; + String dirName = "/export/" + vol.getName(); return disk.getServerName() + ":" + dirName; } + + public ProcessResult getVolumeInfo() { + return new ProcessUtil().executeCommand("gluster", "volume", "info"); + } + public List<Volume> getAllVolumes(String volumeInfoText) { + List<Volume> volumes = new ArrayList<Volume>(); + boolean isBricksGroupFound = false; + boolean isOptionReconfigFound = false; + List<String> bricks = new ArrayList<String>(); + Volume volume = null; + + for (String line : volumeInfoText.split(CoreConstants.NEWLINE)) { + if (extractToken(line, VOLUME_NAME_PFX) != null) { + if (volume != null) { + volume.setDisks(bricks); + bricks.clear(); + volumes.add(volume); + } + volume = new Volume(); + volume.setName(extractToken(line, VOLUME_NAME_PFX)); + isBricksGroupFound = isOptionReconfigFound = false; + continue; + } + + if (extractToken(line, VOLUME_TYPE_PFX) != null) { + String volumeType = extractToken(line, VOLUME_TYPE_PFX); + volume.setVolumeType((volumeType == "Distribute") ? VOLUME_TYPE.PLAIN_DISTRIBUTE + : VOLUME_TYPE.DISTRIBUTED_MIRROR); // TODO: for Stripe + continue; + } + + if (extractToken(line, VOLUME_STATUS_PFX) != null) { + volume.setStatus(extractToken(line, VOLUME_STATUS_PFX).equals("Started") ? VOLUME_STATUS.ONLINE : VOLUME_STATUS.OFFLINE); + continue; + } + + if (extractToken(line, VOLUME_TRANSPORT_TYPE_PFX) != null) { + volume.setTransportType((extractToken(line, + VOLUME_TRANSPORT_TYPE_PFX) == "tcp") ? TRANSPORT_TYPE.ETHERNET + : TRANSPORT_TYPE.INFINIBAND); + continue; + } + + if (extractToken(line, VOLUME_BRICKS_GROUP_PFX) != null) { + isBricksGroupFound = true; + continue; + } + + if (isBricksGroupFound) { + if (line.matches("Brick[0-9]+:.*")) { + bricks.add( line.split(":")[2].trim().split("/")[2].trim() ); // line: "Brick1: server1:/export/md0/volume-name" + continue; + } else { + isBricksGroupFound = false; + } + } + + if (extractToken(line, VOLUME_OPTIONS_RECONFIG_PFX) != null) { + isOptionReconfigFound = true; + continue; + } + + if (isOptionReconfigFound) { + if (extractToken(line, VOLUME_OPTIONS_AUTH_ALLOW) != null) { + volume.setAccessControlList( extractToken(line, VOLUME_OPTIONS_AUTH_ALLOW) ); + isOptionReconfigFound = false; + } + } + } + if (volume != null) {// Adding the last volume parsed + volume.setDisks(bricks); + volumes.add(volume); + } + return volumes; + } + public static void main(String args[]) { - List<String> names = new GlusterUtil().getGlusterServerNames(); - System.out.println(names); +// List<String> names = new GlusterUtil().getGlusterServerNames(); +// System.out.println(names); } } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java index 1c4e6893..45f4c436 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java @@ -25,4 +25,8 @@ public class StringUtil { : sourceString.toLowerCase().contains( filterString.toLowerCase()); } + + public static String removeSpaces(String str) { + return str.replaceAll("\\s+", ""); + } } |
