diff options
Diffstat (limited to 'src/com.gluster.storage.management.server')
2 files changed, 36 insertions, 1 deletions
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java index e635510a..4fc70202 100644 --- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java +++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java @@ -189,6 +189,30 @@ public class VolumesResource { return status; } + @DELETE + @Path("{" + QUERY_PARAM_VOLUME_NAME + "}/" + SUBRESOURCE_DISKS) + @Produces(MediaType.TEXT_XML) + public Status removeBricks(@PathParam(QUERY_PARAM_VOLUME_NAME) String volumeName, + @QueryParam(QUERY_PARAM_DISKS) String disks, @QueryParam(QUERY_PARAM_DELETE_OPTION) String deleteOption) { + List<String> bricks = Arrays.asList(disks.split(",")); // Convert from comma separated string (query parameter) + List<String> volumeBrick = new ArrayList<String>(); + for (String brickInfo : bricks) { + String diskInfo[] = brickInfo.split(":"); + volumeBrick.add(getBrickForDisk(getVolume(volumeName), diskInfo[1])); + } + + Status status = glusterUtil.removeBricks(volumeName, volumeBrick); + + if (status.isSuccess()) { + Status cleanupStatus = cleanupDirectories(bricks, volumeName, bricks.size(), deleteOption); + if (!cleanupStatus.isSuccess()) { + // append cleanup error to prepare brick error + status.setMessage(status.getMessage() + CoreConstants.NEWLINE + cleanupStatus.getMessage()); + } + } + return status; + } + private Status postDelete(String volumeName, List<String> disks, String deleteFlag) { String serverName, diskName, diskInfo[]; Status result; diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java index 3ca11069..fa49a529 100644 --- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java +++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java @@ -184,7 +184,7 @@ public class GlusterUtil { List<String> command = prepareVolumeCreateCommand(volume, bricks, count, volumeType, transportTypeStr); ProcessResult result = processUtil.executeCommand(command); if (!result.isSuccess()) { - // TODO: Perform cleanup on all nodes before returning + // Perform cleanup on all nodes before returning return new Status(result); } @@ -474,6 +474,17 @@ public class GlusterUtil { return new Status(processUtil.executeCommand("gluster", "volume", "replace-brick", volumeName, diskFrom, diskTo, operation)); } + public Status removeBricks(String volumeName, List<String> bricks) { + List<String> command = new ArrayList<String>(); + command.add("gluster"); + command.add("volume"); + command.add("remove-brick"); + command.add(volumeName); + command.addAll(bricks); + return new Status(processUtil.executeCommand(command)); + } + + public static void main(String args[]) { // List<String> names = new GlusterUtil().getGlusterServerNames(); // System.out.println(names); |
