summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDhandapani <dhandapani@gluster.com>2011-04-25 14:54:14 +0530
committerDhandapani <dhandapani@gluster.com>2011-04-25 14:54:14 +0530
commitaebebbf67a78f6330812668800cd08bffdefec6f (patch)
treead4776ea86eb29511c223b4453b98713e4a85677 /src
parent1982e9cbecbfb7dfedef0972dae6107d085d0620 (diff)
parent8af8228a2f2e93be63a041edcd76a3b26f8a0cd9 (diff)
Merge branch 'deletevolume'
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java6
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java3
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java14
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java27
4 files changed, 28 insertions, 22 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java
index e8877321..e1a42de1 100644
--- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java
+++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java
@@ -6,6 +6,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import com.gluster.storage.management.client.utils.ClientUtil;
+import com.gluster.storage.management.core.constants.RESTConstants;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.DefaultClientConfig;
@@ -176,8 +177,9 @@ public abstract class AbstractClient {
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object deleteSubResource(String subResourceName, Class responseClass, String volumeName,
String deleteOption) {
- return resource.path(subResourceName).queryParam("volumeName", volumeName)
- .queryParam("deleteOption", deleteOption).header(HTTP_HEADER_AUTH, authHeader).delete(responseClass);
+ return resource.path(subResourceName).queryParam(RESTConstants.QUERY_PARAM_VOLUME_NAME, volumeName)
+ .queryParam(RESTConstants.QUERY_PARAM_DELETE_OPTION, deleteOption).header(HTTP_HEADER_AUTH, authHeader)
+ .delete(responseClass);
}
public abstract String getResourceName();
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 f44b24e5..0aa286a3 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
@@ -35,7 +35,6 @@ public class RESTConstants {
public static final String FORM_PARAM_VALUE_START = "start";
public static final String FORM_PARAM_VALUE_STOP = "stop";
public static final String FORM_PARAM_OPTION_KEY = "key";
- public static final String FORM_PARAM_VOLUME_NAME = "volumeName";
public static final String FORM_PARAM_OPTION_VALUE = "value";
public static final String PATH_PARAM_VOLUME_NAME = "volumeName";
@@ -43,6 +42,8 @@ public class RESTConstants {
public static final String QUERY_PARAM_DISK_NAME = "diskName";
public static final String QUERY_PARAM_LINE_COUNT = "lineCount";
+ public static final String QUERY_PARAM_VOLUME_NAME = "volumeName";
+ public static final String QUERY_PARAM_DELETE_OPTION = "deleteOption";
// Running tasks resource
public static final String RESOURCE_PATH_RUNNING_TASKS = "/cluster/runningtasks";
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java
index 2a213acc..d7731364 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/DeleteVolumeAction.java
@@ -42,11 +42,11 @@ public class DeleteVolumeAction extends AbstractActionDelegate {
if (volume.getStatus() == VOLUME_STATUS.OFFLINE) {
warningMessage = "Are you sure to delete the Volume[" + volume.getName() + "] ?";
} else {
- warningMessage = "Volume [" + volume.getName() + "] is running, \nAre you sure to continue?";
+ warningMessage = "Volume [" + volume.getName() + "] is online, \nAre you sure to continue?";
}
- Integer deleteOption = new MessageDialog(getShell(), "Gluster Storage Platform", GUIHelper.getInstance().getImage(
- IImageKeys.SERVER), warningMessage, MessageDialog.INFORMATION, new String[] { "Cancel",
+ Integer deleteOption = new MessageDialog(getShell(), "Delete Volume", GUIHelper.getInstance().getImage(
+ IImageKeys.VOLUME), warningMessage, MessageDialog.QUESTION, new String[] { "Cancel",
"Delete volume and it's data", "Delete volume, keep back-up of data" }, 2).open();
if (deleteOption == 0) {
return;
@@ -58,7 +58,7 @@ public class DeleteVolumeAction extends AbstractActionDelegate {
if (volume.getStatus() == VOLUME_STATUS.ONLINE) { // To stop the volume service, if running
status = client.stopVolume(volume.getName());
if (!status.isSuccess()) {
- showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] could not be stopped! Error: [" + status.getMessage()
+ showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] could not be stopped! Error: [" + status
+ "]");
return;
}
@@ -70,11 +70,11 @@ public class DeleteVolumeAction extends AbstractActionDelegate {
modelManager.deleteVolume(volume);
} else {
if (status.isPartSuccess()) {
- showWarningDialog(actionDesc, "Volume deleted, but following error(s) occured: " + status.getMessage());
+ showWarningDialog(actionDesc, "Volume deleted, but following error(s) occured: " + status);
modelManager.deleteVolume(volume);
} else {
- showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] could not be deleted! Error: [" + status.getMessage()
- + "]");
+ showErrorDialog(actionDesc,
+ "Volume [" + volume.getName() + "] could not be deleted! Error: [" + status + "]");
}
}
}
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 92fba9f3..e30462f2 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
@@ -26,6 +26,8 @@ import static com.gluster.storage.management.core.constants.RESTConstants.FORM_P
import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_VOLUME_NAME;
import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DISK_NAME;
import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_LINE_COUNT;
+import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_VOLUME_NAME;
+import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DELETE_OPTION;
import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_VOLUMES;
import static com.gluster.storage.management.core.constants.RESTConstants.SUBRESOURCE_DEFAULT_OPTIONS;
import static com.gluster.storage.management.core.constants.RESTConstants.SUBRESOURCE_LOGS;
@@ -143,7 +145,8 @@ public class VolumesResource {
@DELETE
@Path("{" + PATH_PARAM_VOLUME_NAME + "}")
@Produces(MediaType.TEXT_XML)
- public Status deleteVolume(@QueryParam("volumeName") String volumeName, @QueryParam("deleteOption") int deleteOption) {
+ public Status deleteVolume(@QueryParam(QUERY_PARAM_VOLUME_NAME) String volumeName,
+ @QueryParam(QUERY_PARAM_DELETE_OPTION) int deleteOption) {
Volume volume = glusterUtil.getVolume(volumeName);
Status status = glusterUtil.deleteVolume(volumeName);
@@ -257,38 +260,38 @@ public class VolumesResource {
}
return new Status(Status.STATUS_CODE_SUCCESS, "Directories cleaned up successfully!");
}
-
+
private List<LogMessage> getDiskLogs(String volumeName, String diskName, Integer lineCount)
throws GlusterRuntimeException {
- String[] diskParts = diskName.split(":");
+ String[] diskParts = diskName.split(":");
String server = diskParts[0];
String disk = diskParts[1];
-
+
// Usage: get_volume_disk_log.py <volumeName> <diskName> <lineCount>
Status logStatus = (Status) serverUtil.executeOnServer(true, server, VOLUME_DISK_LOG_SCRIPT + " " + volumeName
+ " " + disk + " " + lineCount, Status.class);
- if(!logStatus.isSuccess()) {
+ if (!logStatus.isSuccess()) {
throw new GlusterRuntimeException(logStatus.toString());
}
-
+
return extractLogMessages(logStatus.getMessage());
}
private List<LogMessage> extractLogMessages(String logContent) {
List<LogMessage> logMessages = new ArrayList<LogMessage>();
- for(String logMessage : logContent.split(CoreConstants.NEWLINE)) {
+ for (String logMessage : logContent.split(CoreConstants.NEWLINE)) {
logMessages.add(new LogMessage(logMessage));
}
-
+
return logMessages;
}
-
+
@GET
@Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + SUBRESOURCE_LOGS)
public LogMessageListResponse getLogs(@PathParam(PATH_PARAM_VOLUME_NAME) String volumeName,
@QueryParam(QUERY_PARAM_DISK_NAME) String diskName, @QueryParam(QUERY_PARAM_LINE_COUNT) Integer lineCount) {
List<LogMessage> logMessages = null;
-
+
try {
if (diskName == null || diskName.isEmpty()) {
logMessages = new ArrayList<LogMessage>();
@@ -304,7 +307,7 @@ public class VolumesResource {
} catch (Exception e) {
return new LogMessageListResponse(new Status(e), null);
}
-
+
return new LogMessageListResponse(Status.STATUS_SUCCESS, logMessages);
}
@@ -325,7 +328,7 @@ public class VolumesResource {
// Status status = vr.createVolume(volume);
// System.out.println(status.getMessage());
Form form = new Form();
- form.add(RESTConstants.FORM_PARAM_VOLUME_NAME, volume.getName());
+ form.add("volumeName", volume.getName());
form.add(RESTConstants.FORM_PARAM_DELETE_OPTION, 1);
Status status = vr.deleteVolume("Vol2", 1);
System.out.println("Code : " + status.getCode());