diff options
| author | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-07-24 09:00:24 -0700 |
|---|---|---|
| committer | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-07-24 09:00:24 -0700 |
| commit | 069be5f7df55052c6b1e00ea7580d94aa97e142b (patch) | |
| tree | 1fc6dea47b6a8c0b568af4f445fb792bd4debf29 /src/com.gluster.storage.management.server | |
| parent | 0075542d9b5a27b3f7eb401dd833e1b24ad666cb (diff) | |
| parent | e4be833158e0e311b7c9fc271357b8a43d67ec20 (diff) | |
Merge pull request #147 from Selvasundaram/master
Brick status updates and brick status icon changes in bricks view
Diffstat (limited to 'src/com.gluster.storage.management.server')
2 files changed, 31 insertions, 7 deletions
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/v1_0/KeysResource.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/v1_0/KeysResource.java index 5ac37bd1..af64af47 100644 --- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/v1_0/KeysResource.java +++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/v1_0/KeysResource.java @@ -82,16 +82,33 @@ public class KeysResource extends AbstractResource { String targetPemFile = targetDir + File.separator + SshUtil.PEM_FILE.getName(); String targetPubKeyFile = targetDir + File.separator + SshUtil.PUBLIC_KEY_FILE.getName(); + if (!SshUtil.PEM_FILE.isFile()) { + throw new GlusterRuntimeException("No private key file [" + SshUtil.PEM_FILE.getName() + "] found!" ); + } + + if (!SshUtil.PUBLIC_KEY_FILE.isFile()) { + throw new GlusterRuntimeException("No public key file [" + SshUtil.PUBLIC_KEY_FILE.getName() + "] found!" ); + } + // Copy keys to temp folder - processUtil.executeCommand("cp", sourcePemFile, targetPemFile); - processUtil.executeCommand("cp", sourcePubKeyFile, targetPubKeyFile); - - // To zip the key files - processUtil.executeCommand("tar", "cvf", zipFile, "-C", "/tmp", SshUtil.PEM_FILE.getName(), + ProcessResult result = processUtil.executeCommand("cp", sourcePemFile, targetPemFile); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Failed to copy key files! [" + result.getOutput() + "]"); + } + result = processUtil.executeCommand("cp", sourcePubKeyFile, targetPubKeyFile); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Failed to copy key files! [" + result.getOutput() + "]"); + } + + // To compress the key files + result = processUtil.executeCommand("tar", "cvf", zipFile, "-C", "/tmp", SshUtil.PEM_FILE.getName(), SshUtil.PUBLIC_KEY_FILE.getName()); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Failed to compress key files! [" + result.getOutput() + "]"); + } // To remove the copied key files - processUtil.executeCommand("rm", "-f", targetPubKeyFile, targetPubKeyFile); + processUtil.executeCommand("rm", "-f", targetPubKeyFile, targetPubKeyFile); // Ignore the errors if any return zipFile; } 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 304da012..22da9ca3 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 @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.regex.Pattern; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -410,7 +411,13 @@ public class GlusterUtil { } private void addBrickToVolume(Volume volume, String serverName, String brickDir, BRICK_STATUS status) { - volume.addBrick(new Brick(serverName, status, brickDir.split("/")[2].trim(), brickDir)); + //If brick directory has standard path, find and assign device name otherwise null + String stdBrickDirPattern = "^/export/.*/.*"; // e.g: /export/sdb/test + String deviceName = null; + if (Pattern.matches(stdBrickDirPattern, brickDir) ) { + deviceName = brickDir.split("/")[2].trim(); + } + volume.addBrick(new Brick(serverName, status, deviceName, brickDir)); } // Do not throw exception, Gracefully handle as Offline brick. |
