summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java2
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java20
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java4
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/SshUtil.java11
4 files changed, 28 insertions, 9 deletions
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 43435675..424fbca7 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
@@ -144,7 +144,7 @@ public class VolumesClient extends AbstractClient {
}
public void downloadLogs(String volumeName, String filePath) {
- downloadSubResource((volumeName) + "/" + RESTConstants.RESOURCE_LOGS + "/" + RESTConstants.RESOURCE_DOWNLOAD, filePath);
+ downloadSubResource(volumeName + "/" + RESTConstants.RESOURCE_LOGS + "/" + RESTConstants.RESOURCE_DOWNLOAD, filePath);
}
public Status removeBricks(String volumeName, List<Brick> BrickList, boolean deleteOption) {
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 c14290f8..7ef917bd 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
@@ -427,15 +427,24 @@ public class VolumesResource {
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_LOGS + "/" + RESOURCE_DOWNLOAD)
- public StreamingOutput getLogs(@PathParam(PATH_PARAM_CLUSTER_NAME) final String clusterName,
+ public StreamingOutput downloadLogs(@PathParam(PATH_PARAM_CLUSTER_NAME) final String clusterName,
@PathParam(PATH_PARAM_VOLUME_NAME) final String volumeName) {
+ final ClusterInfo cluster = clusterService.getCluster(clusterName);
+ if(cluster == null) {
+ throw new GlusterRuntimeException("Cluster [" + clusterName + "] doesn't exist!");
+ }
+
+ final Volume volume = (Volume)getVolume(clusterName, volumeName).getData();
+ if(volume == null) {
+ throw new GlusterRuntimeException("Volume [" + volumeName + "] doesn't exist in cluster [" + clusterName
+ + "]!");
+ }
+
return new StreamingOutput() {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
- Volume volume = (Volume)getVolume(clusterName, volumeName).getData();
try {
- // TODO: pass clusterName to downloadLogs
File archiveFile = new File(downloadLogs(volume));
output.write(fileUtil.readFileAsByteArray(archiveFile));
archiveFile.delete();
@@ -457,8 +466,7 @@ public class VolumesResource {
String logFileName = glusterUtil.getLogFileNameForBrickDir(brick.getBrickDirectory());
String logFilePath = logDir + CoreConstants.FILE_SEPARATOR + logFileName;
- String logContents = serverUtil.getFileFromServer(brick.getServerName(), logFilePath);
- fileUtil.createTextFile(tempDirPath + CoreConstants.FILE_SEPARATOR + logFileName, logContents);
+ serverUtil.getFileFromServer(brick.getServerName(), logFilePath, tempDirPath);
}
String gzipPath = fileUtil.getTempDirName() + CoreConstants.FILE_SEPARATOR + volume.getName() + "-logs.tar.gz";
@@ -479,7 +487,7 @@ public class VolumesResource {
@QueryParam(QUERY_PARAM_FROM_TIMESTAMP) String fromTimestamp,
@QueryParam(QUERY_PARAM_TO_TIMESTAMP) String toTimestamp,
@QueryParam(QUERY_PARAM_LINE_COUNT) Integer lineCount) {
- List<LogMessage> logMessages = null;
+ List<VolumeLogMessage> logMessages = null;
ClusterInfo cluster = clusterService.getCluster(clusterName);
if(cluster == null) {
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java
index 2a055ee8..ed1aea75 100644
--- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java
+++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java
@@ -161,8 +161,8 @@ public class ServerUtil {
// }
// }
- public String getFileFromServer(String serverName, String fileName) {
- return executeOnServer(serverName, "get_file " + fileName);
+ public void getFileFromServer(String serverName, String remoteFileName, String localDirName) {
+ sshUtil.getFile(serverName, remoteFileName, localDirName);
}
/**
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/SshUtil.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/SshUtil.java
index 1cc51d23..a4728d21 100644
--- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/SshUtil.java
+++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/SshUtil.java
@@ -80,6 +80,17 @@ public class SshUtil {
}
}
+ public void getFile(String serverName, String remoteFile, String localDir) {
+ try {
+ Connection conn = getConnection(serverName);
+ SCPClient scpClient = new SCPClient(conn);
+ scpClient.get(remoteFile, localDir);
+ } catch (IOException e) {
+ throw new GlusterRuntimeException("Error while fetching file [" + remoteFile + "] from server ["
+ + serverName + "]", e);
+ }
+ }
+
public synchronized void installPublicKey(String serverName) {
Connection conn = getConnectionWithPassword(serverName);
SCPClient scpClient = new SCPClient(conn);