diff options
author | Selvasundaram <selvam@gluster.com> | 2011-11-24 15:27:33 +0530 |
---|---|---|
committer | Selvasundaram <selvam@gluster.com> | 2011-11-25 18:49:53 +0530 |
commit | 6a7ca2f7733d15f57d278275f55d65c5de0c561e (patch) | |
tree | 5851a7015a6de2314298dc85c890ef4df8a1c421 | |
parent | 8ceca6ee92099b5f356bcc57198e70225647e65a (diff) |
Mount point parameter enclosed in quotes
9 files changed, 110 insertions, 76 deletions
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 cb3519b1..5fefedc0 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 @@ -30,6 +30,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.ServerStats; +import com.gluster.storage.management.core.response.FsTypeListResponse; import com.gluster.storage.management.core.response.GlusterServerListResponse; import com.gluster.storage.management.core.response.StringListResponse; import com.gluster.storage.management.core.utils.GlusterCoreUtil; @@ -77,10 +78,10 @@ public class GlusterServersClient extends AbstractClient { return postRequest(form); } - public List<String> getFSType(String serverName) { - List<String> fsType = ((StringListResponse) fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_FSTYPE, - StringListResponse.class)).getData(); - return fsType; + public List<String> getFSTypes(String serverName) { + FsTypeListResponse fsTypeListResponse = ((FsTypeListResponse) fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_FSTYPES, + FsTypeListResponse.class)); + return fsTypeListResponse.getFsTypes(); } public URI initializeDisk(String serverName, String diskName, String fsType, String mountPoint) { diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitializeDiskTypeSelection.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitDiskDialog.java index b484d6d2..870de286 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitializeDiskTypeSelection.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitDiskDialog.java @@ -46,24 +46,23 @@ import org.eclipse.ui.forms.widgets.Hyperlink; import com.gluster.storage.management.console.utils.GUIHelper; -public class InitializeDiskTypeSelection extends Dialog { +public class InitDiskDialog extends Dialog { private Combo formatTypeCombo = null; private final GUIHelper guiHelper = GUIHelper.getInstance(); private Composite initializeDiskTypeComposite; private Composite composite; private String fsType; - private String mountPointText; - private Text mountPoint; + private String mountPoint; + private Text mountPointText; private String deviceName; - private List<String> possibleFsType; - private String defaultMountPoint = "/export/"; + private List<String> fsTypes; + private static final String DEFAULT_MOUNT_POINT = "/export/"; - public InitializeDiskTypeSelection(Shell parentShell, String formatingDeviceName, List<String> possibleFsType) { + public InitDiskDialog(Shell parentShell, String deviceName, List<String> fsTypes) { super(parentShell); - this.possibleFsType = possibleFsType; - this.deviceName = formatingDeviceName; - // TODO Auto-generated constructor stub + this.fsTypes = fsTypes; + this.deviceName = deviceName; } @Override @@ -127,24 +126,23 @@ public class InitializeDiskTypeSelection extends Dialog { private void createFormatTypeCombo(Composite composite) { formatTypeCombo = new Combo(composite, SWT.READ_ONLY); - formatTypeCombo.setItems(possibleFsType.toArray(new String[0])); + formatTypeCombo.setItems(fsTypes.toArray(new String[0])); formatTypeCombo.select(0); new Label(composite, SWT.NONE); } private void createMountPointText(Composite container) { - mountPoint = new Text(container, SWT.BORDER); + mountPointText = new Text(container, SWT.BORDER); GridData txtNameData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - txtNameData.horizontalSpan = 1; txtNameData.widthHint = 400; - mountPoint.setTextLimit(100); - mountPoint.setLayoutData(txtNameData); - mountPoint.setText(defaultMountPoint + deviceName); - mountPoint.setEnabled(false); - mountPoint.addModifyListener(new ModifyListener() { + mountPointText.setTextLimit(100); + mountPointText.setLayoutData(txtNameData); + mountPointText.setText(DEFAULT_MOUNT_POINT + deviceName); + mountPointText.setEnabled(false); + mountPointText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { - validateMountPoint(mountPoint.getText().trim()); + validateMountPoint(); } }); } @@ -156,26 +154,11 @@ public class InitializeDiskTypeSelection extends Dialog { changeLink.setForeground(new Color(Display.getDefault(), 0, 0, 255)); changeLink.addHyperlinkListener(new HyperlinkAdapter() { - - // private void finishEdit() { - // changeLink.setText("change"); - // mountPoint.setEnabled(false); - // } - - private void startEdit() { - // changeLink.setText("update"); - changeLink.setVisible(false); - mountPoint.setEnabled(true); - } - @Override public void linkActivated(HyperlinkEvent e) { - if (mountPoint.isEnabled()) { - // we were already in edit mode. - // finishEdit(); - } else { - // Get in to edit mode - startEdit(); + if (!mountPointText.isEnabled()) { + changeLink.setVisible(false); + mountPointText.setEnabled(true); } } }); @@ -184,11 +167,11 @@ public class InitializeDiskTypeSelection extends Dialog { @Override protected void okPressed() { fsType = formatTypeCombo.getText().trim(); - mountPointText = mountPoint.getText().trim(); + mountPoint = mountPointText.getText().trim(); if (validateForm()) { super.okPressed(); } else { - MessageDialog.openError(getShell(), "Error: Validation error!", "Empty or Invalid mountpoint."); + MessageDialog.openError(getShell(), "Initialize Disk - Error", "Please enter a valid mount point"); } } @@ -197,15 +180,16 @@ public class InitializeDiskTypeSelection extends Dialog { super.cancelPressed(); } - private boolean validateMountPoint(String deviceMountPoint) { - if (deviceMountPoint.isEmpty()) { + private boolean validateMountPoint() { + String mountPoint = mountPointText.getText().trim(); + if (mountPoint.isEmpty()) { return false; } - return deviceMountPoint.matches("^/.+"); + return mountPoint.matches("^/.+"); } private boolean validateForm() { - return (!formatTypeCombo.getText().trim().isEmpty() && validateMountPoint( mountPoint.getText().trim())); + return (!formatTypeCombo.getText().trim().isEmpty() && validateMountPoint()); } /** @@ -223,6 +207,6 @@ public class InitializeDiskTypeSelection extends Dialog { } public String getMountPoint() { - return mountPointText; + return mountPoint; } } diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java index b131ccc2..43a7e61a 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java @@ -45,7 +45,8 @@ import com.gluster.storage.management.client.TasksClient; import com.gluster.storage.management.console.Application; import com.gluster.storage.management.console.GlusterDataModelManager; import com.gluster.storage.management.console.IEntityListener; -import com.gluster.storage.management.console.dialogs.InitializeDiskTypeSelection; +import com.gluster.storage.management.console.dialogs.InitDiskDialog; +import com.gluster.storage.management.console.utils.GlusterLogger; import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.ClusterListener; import com.gluster.storage.management.core.model.DefaultClusterListener; @@ -61,6 +62,7 @@ import com.gluster.storage.management.core.model.TaskInfo; public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage<Disk> implements IEntityListener { protected List<Disk> disks; + protected static final GlusterLogger logger = GlusterLogger.getInstance(); /** * @return Index of the "status" column in the table. Return -1 if status column is not displayed @@ -71,7 +73,7 @@ public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage<Disk super(site, parent, style, false, true, disks); this.disks = disks; - // creates hyperlinks for "unitialized" disks + // creates hyperlinks for "uninitialized" disks setupStatusCellEditor(); // Listen for disk status change events Application.getApplication().addEntityListener(this); @@ -252,25 +254,25 @@ public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage<Disk TaskInfo existingTaskInfo = modelManager.getTaskByReference(reference); if (existingTaskInfo != null && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_FAILURE) { - MessageDialog.openInformation(getShell(), "Error: Initialize disk", "Initializing disk [" + reference + MessageDialog.openInformation(getShell(), "Initialize disk - Error", "Initializing disk [" + reference + "] is already in progress! Try later."); return; } // To collect the available fsType GlusterServersClient serversClient = new GlusterServersClient(); - List<String> possibleFsType = new ArrayList<String>(); + List<String> fsTypes = new ArrayList<String>(); try { - possibleFsType = serversClient.getFSType(device.getServerName()); - } catch (GlusterRuntimeException eFsType) { - MessageDialog.openError(getShell(), "Error: File System Type", eFsType.getMessage()); + fsTypes = serversClient.getFSTypes(device.getServerName()); + } catch (GlusterRuntimeException e1) { + MessageDialog.openError(getShell(), "Initialize disk - Error", e1.getMessage()); return; } - InitializeDiskTypeSelection formatDialog = new InitializeDiskTypeSelection(getShell(), device.getName(), possibleFsType); + InitDiskDialog formatDialog = new InitDiskDialog(getShell(), device.getName(), fsTypes); int userAction = formatDialog.open(); if (userAction == Window.CANCEL) { - formatDialog.cancelPressed(); + // formatDialog.cancelPressed(); return; } @@ -296,12 +298,12 @@ public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage<Disk // GlusterDataModelManager.getInstance().updateDeviceStatus(device.getServerName(), device.getName(), // DEVICE_STATUS.INITIALIZED); } else { - MessageDialog.openError(getShell(), "Error: Initialize disk", taskInfo.getStatus().getMessage()); + MessageDialog.openError(getShell(), "Initialize disk - Error", taskInfo.getStatus().getMessage()); } guiHelper.showTaskView(); } catch (Exception e1) { - e1.printStackTrace(); - MessageDialog.openError(getShell(), "Error: Initialize disk", e1.getMessage()); + logger.error("Exception while initialize disk", e1); + MessageDialog.openError(getShell(), "Initialize disk - Error", e1.getMessage()); } } } 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 99171c3e..4b1251b6 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 @@ -44,7 +44,7 @@ public class RESTConstants { public static final String RESOURCE_KEYS = "keys"; public static final String RESOURCE_STATISTICS = "statistics"; public static final String RESOURCE_USERS = "users"; - public static final String RESOURCE_FSTYPE = "fstype"; + public static final String RESOURCE_FSTYPES = "fstypes"; public static final String TASK_START = "start"; public static final String TASK_PAUSE = "pause"; diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/FsTypeListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/FsTypeListResponse.java new file mode 100644 index 00000000..0235fa5f --- /dev/null +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/FsTypeListResponse.java @@ -0,0 +1,47 @@ +/** + * FsTypesListResponse.java + * + * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com> + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * <http://www.gnu.org/licenses/>. + */ +package com.gluster.storage.management.core.response; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "fsTypes") +public class FsTypeListResponse { + private List<String> fsTypes; + + public FsTypeListResponse() { + } + + public FsTypeListResponse(List<String> fsTypes) { + setFsTypes(fsTypes); + } + + @XmlElement(name = "fsType", type=String.class) + public List<String> getFsTypes() { + return fsTypes; + } + + public void setFsTypes(List<String> fsTypes) { + this.fsTypes = fsTypes; + } +} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java index ccb11726..3c6910fd 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java @@ -19,8 +19,8 @@ package com.gluster.storage.management.gateway.resources.v1_0; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FSTYPE; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_MOUNTPOINT; +import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_DISK_NAME; import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_SERVER_NAME; @@ -31,7 +31,7 @@ import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_ import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_PERIOD; import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_TYPE; import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DISKS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_FSTYPE; +import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_FSTYPES; import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_SERVERS; import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_STATISTICS; @@ -63,9 +63,9 @@ import com.gluster.storage.management.core.exceptions.GlusterValidationException import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.ServerStats; import com.gluster.storage.management.core.model.TaskStatus; +import com.gluster.storage.management.core.response.FsTypeListResponse; import com.gluster.storage.management.core.response.GlusterServerListResponse; import com.gluster.storage.management.core.response.ServerNameListResponse; -import com.gluster.storage.management.core.response.StringListResponse; import com.gluster.storage.management.gateway.data.ClusterInfo; import com.gluster.storage.management.gateway.services.ClusterService; import com.gluster.storage.management.gateway.services.GlusterServerService; @@ -202,9 +202,10 @@ public class GlusterServersResource extends AbstractResource { @GET @Produces(MediaType.APPLICATION_XML) - @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_FSTYPE) - public StringListResponse getFsType(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { - return glusterServerService.getFsType(clusterName, serverName); + @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_FSTYPES) + public FsTypeListResponse getFsTypes(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { + List<String> fsTypes = glusterServerService.getFsTypes(clusterName, serverName); + return new FsTypeListResponse(fsTypes); } @PUT diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java index fcaec52e..b20fb2fe 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java @@ -520,11 +520,11 @@ public class GlusterServerService { } } - public StringListResponse getFsType(String clusterName, String serverName) { + public List<String> getFsTypes(String clusterName, String serverName) { if (isValidServer(clusterName, serverName)) { - return serverUtil.getFsType(serverName); + return serverUtil.getFsTypes(serverName); } else { - throw new GlusterRuntimeException(serverName + " is not belongs to the cluster [" + clusterName + "]"); + throw new GlusterRuntimeException(serverName + " does not belong to the cluster [" + clusterName + "]"); } } } diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java index ffb9619d..73b1e78f 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java @@ -47,7 +47,7 @@ public class InitializeDiskTask extends Task { private ServerUtil serverUtil; public InitializeDiskTask(ClusterService clusterService, String clusterName, String serverName, String diskName, - String fsType, String deviceMountPoint) { + String fsType, String mountPoint) { // Reference contains "Server:disk" super(clusterService, clusterName, TASK_TYPE.DISK_FORMAT, serverName + ":" + diskName, "Initialize disk " + serverName + ":" + diskName, false, false, false); @@ -55,7 +55,7 @@ public class InitializeDiskTask extends Task { setServerName(serverName); setDiskName(diskName); setFsType(fsType); - setMountpoint(deviceMountPoint); + setMountpoint(mountPoint); taskInfo.setName(getId()); init(); } @@ -119,8 +119,8 @@ public class InitializeDiskTask extends Task { } private void startInitializeDisk(String serverName) { - String output = serverUtil.executeScriptOnServer(serverName, INITIALIZE_DISK_SCRIPT + getFsType() + " " - + mountPoint + " " + getDiskName() ); + String output = serverUtil.executeScriptOnServer(serverName, INITIALIZE_DISK_SCRIPT + " " + getFsType() + " \"" + + getMountpoint() + "\" " + getDiskName() ); TaskStatus taskStatus = new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, output)); taskStatus.setPercentageSupported((getFsType().equals(GlusterConstants.FSTYPE_XFS)) ? false : true); getTaskInfo().setStatus(taskStatus); diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java index b53d0042..63f2bbf4 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java @@ -363,9 +363,8 @@ public class ServerUtil { return ctx.getBean(clazz); } - public StringListResponse getFsType(String serverName) { + public List<String> getFsTypes(String serverName) { String output = executeScriptOnServer(serverName, REMOTE_SCRIPT_GET_FILE_SYSTEM_TYPE); - StringListResponse response = new StringListResponse(Arrays.asList(output.trim().split(CoreConstants.NEWLINE))); - return response; + return Arrays.asList(output.trim().split(CoreConstants.NEWLINE)); } } |