summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSelvasundaram <selvam@gluster.com>2011-08-22 22:07:05 +0530
committerSelvasundaram <selvam@gluster.com>2011-08-22 22:07:05 +0530
commit805df15c3e1f540fd94bf1f1937de66f459a0900 (patch)
tree92f8fdbb59d3cad18ebcf6f96e8f6e0b0b6095f8 /src
parent297ad1e51bdd4de3b798b9df362f9d0ca27abbda (diff)
parent2c70473c890497321403970c37508626cd0d0dd6 (diff)
Merge branch 'master' of github.com:gluster/console
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.console/icons/tango/16x16/arrow-down.pngbin703 -> 683 bytes
-rw-r--r--src/com.gluster.storage.management.console/icons/tango/16x16/arrow-up.pngbin712 -> 652 bytes
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh7
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java2
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java14
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/NetworkStatsFactory.java7
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java12
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java61
8 files changed, 59 insertions, 44 deletions
diff --git a/src/com.gluster.storage.management.console/icons/tango/16x16/arrow-down.png b/src/com.gluster.storage.management.console/icons/tango/16x16/arrow-down.png
index 7f23e3f4..3dd7fccd 100644
--- a/src/com.gluster.storage.management.console/icons/tango/16x16/arrow-down.png
+++ b/src/com.gluster.storage.management.console/icons/tango/16x16/arrow-down.png
Binary files differ
diff --git a/src/com.gluster.storage.management.console/icons/tango/16x16/arrow-up.png b/src/com.gluster.storage.management.console/icons/tango/16x16/arrow-up.png
index b8ad3050..fa9a7d71 100644
--- a/src/com.gluster.storage.management.console/icons/tango/16x16/arrow-up.png
+++ b/src/com.gluster.storage.management.console/icons/tango/16x16/arrow-up.png
Binary files differ
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh b/src/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh
index 4edf0ffd..6c7ac998 100755
--- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh
+++ b/src/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh
@@ -10,12 +10,17 @@ if [ $# -ne 1 ]; then
exit ${USAGE_ERR}
fi
+CURR_DIR=${PWD}
+SCRIPT_PATH=`readlink -f ${0}`
+GLUSTERMG_DIR=`dirname ${SCRIPT_PATH}`
+
# Main action body
+cd ${GLUSTERMG_DIR}
cd ..
for FILE in WEB-INF/lib/*.jar
do
export CLASSPATH=${CLASSPATH}:${PWD}/${FILE}
done
export CLASSPATH=${PWD}/WEB-INF/classes:${CLASSPATH}
-cd -
+cd ${CURR_DIR}
java com.gluster.storage.management.gateway.utils.PasswordManager reset ${1}
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java
index 76c8aca8..852d7365 100644
--- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java
+++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java
@@ -167,7 +167,7 @@ public class ClusterService {
for(GlusterServer glusterServer : glusterServers) {
String serverName = glusterServer.getName();
- glusterServerService.fetchServerDetails(glusterServer);
+ serverUtil.fetchServerDetails(glusterServer);
if(glusterServer.isOnline()) {
checkAndSetupPublicKey(serverName);
}
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 f69b4a75..f80d68ac 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
@@ -34,7 +34,6 @@ import com.gluster.storage.management.core.exceptions.GlusterRuntimeException;
import com.gluster.storage.management.core.exceptions.GlusterValidationException;
import com.gluster.storage.management.core.model.GlusterServer;
import com.gluster.storage.management.core.model.Server;
-import com.gluster.storage.management.core.model.Server.SERVER_STATUS;
import com.gluster.storage.management.core.utils.GlusterCoreUtil;
import com.gluster.storage.management.core.utils.ProcessUtil;
import com.gluster.storage.management.gateway.data.ClusterInfo;
@@ -68,15 +67,6 @@ public class GlusterServerService {
private static final Logger logger = Logger.getLogger(GlusterServerService.class);
- public void fetchServerDetails(GlusterServer server) {
- try {
- server.setStatus(SERVER_STATUS.ONLINE);
- serverUtil.fetchServerDetails(server);
- } catch (ConnectionException e) {
- server.setStatus(SERVER_STATUS.OFFLINE);
- }
- }
-
public List<GlusterServer> getGlusterServers(String clusterName, boolean fetchDetails, Integer maxCount,
String previousServerName) {
List<GlusterServer> glusterServers;
@@ -213,7 +203,7 @@ public class GlusterServerService {
public void run() {
try {
logger.info("fetching details of server [" + server.getName() + "] - start");
- fetchServerDetails(server);
+ serverUtil.fetchServerDetails(server);
logger.info("fetching details of server [" + server.getName() + "] - end");
} catch (Exception e) {
logger.error("fetching details of server [" + server.getName() + "] - error", e);
@@ -264,7 +254,7 @@ public class GlusterServerService {
}
if (fetchDetails && server.isOnline()) {
- fetchServerDetails(server);
+ serverUtil.fetchServerDetails(server);
}
return server;
}
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/NetworkStatsFactory.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/NetworkStatsFactory.java
index efac10fb..fdc4b1d2 100644
--- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/NetworkStatsFactory.java
+++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/NetworkStatsFactory.java
@@ -54,6 +54,13 @@ public class NetworkStatsFactory extends AbstractStatsFactory {
String serverName = serverNames.get(i);
Server server = new Server(serverName);
serverUtil.fetchServerDetails(server);
+ if(!server.isOnline()) {
+ if(removeServerOnError) {
+ // server is offline. no point in trying to fetch it's details.
+ serverNames.remove(serverName);
+ }
+ continue;
+ }
try {
for(NetworkInterface networkInterface : server.getNetworkInterfaces()) {
ServerStats stats = fetchStats(serverName, period, networkInterface.getName());
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 f762baf5..d31411ec 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
@@ -37,9 +37,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.gluster.storage.management.core.constants.CoreConstants;
+import com.gluster.storage.management.core.exceptions.ConnectionException;
import com.gluster.storage.management.core.exceptions.GlusterRuntimeException;
import com.gluster.storage.management.core.model.Server;
import com.gluster.storage.management.core.model.Status;
+import com.gluster.storage.management.core.model.Server.SERVER_STATUS;
import com.gluster.storage.management.core.utils.ProcessResult;
import com.gluster.storage.management.core.utils.ProcessUtil;
@@ -95,9 +97,13 @@ public class ServerUtil {
* Server whose details are to be fetched
*/
public void fetchServerDetails(Server server) {
- Object response = fetchServerDetails(server.getName());
- server.copyFrom((Server) response); // Update the details in <Server> object
- server.setDisks(((Server) response).getDisks());
+ try {
+ Server serverDetails = (Server)fetchServerDetails(server.getName());
+ server.copyFrom(serverDetails); // Update the details in <Server> object
+ server.setDisks(serverDetails.getDisks());
+ } catch (ConnectionException e) {
+ server.setStatus(SERVER_STATUS.OFFLINE);
+ }
}
public boolean isServerOnline(Server server) {
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java
index ed45305d..b3e9072a 100644
--- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java
+++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java
@@ -23,6 +23,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.net.NoRouteToHostException;
import java.util.Arrays;
import org.apache.log4j.Logger;
@@ -75,7 +76,7 @@ public class SshUtil {
try {
getConnectionWithPassword(serverName).close();
return true;
- } catch(ConnectionException e) {
+ } catch(Exception e) {
return false;
}
}
@@ -170,7 +171,19 @@ public class SshUtil {
private synchronized Connection getConnectionWithPassword(String serverName) {
Connection conn = createConnection(serverName);
- authenticateWithPassword(conn);
+ if(!authenticateWithPassword(conn)) {
+ throw new ConnectionException("SSH Authentication (password) failed for server ["
+ + conn.getHostname() + "]");
+ }
+ return conn;
+ }
+
+ private synchronized Connection getConnectionWithPubKey(String serverName) {
+ Connection conn = createConnection(serverName);
+ if(!authenticateWithPublicKey(conn)) {
+ throw new ConnectionException("SSH Authentication (public key) failed for server ["
+ + conn.getHostname() + "]");
+ }
return conn;
}
@@ -182,15 +195,19 @@ public class SshUtil {
conn = createConnection(serverName);
try {
- authenticateWithPublicKey(conn);
+ if(!authenticateWithPublicKey(conn)) {
+ if(!authenticateWithPassword(conn)) {
+ conn.close();
+ throw new ConnectionException("SSH authentication failed on server [" + serverName + "]!");
+ }
+ }
} catch(Exception e) {
// authentication failed. close the connection.
conn.close();
if(e instanceof GlusterRuntimeException) {
throw (GlusterRuntimeException)e;
} else {
- throw new GlusterRuntimeException("Exception during authentication with public key on server ["
- + serverName + "]", e);
+ throw new GlusterRuntimeException("Exception during authentication on server [" + serverName + "]", e);
}
}
@@ -198,7 +215,7 @@ public class SshUtil {
return conn;
}
- private void authenticateWithPublicKey(Connection conn) {
+ private boolean authenticateWithPublicKey(Connection conn) {
try {
if (!supportsPublicKeyAuthentication(conn)) {
throw new ConnectionException("Public key authentication not supported on [" + conn.getHostname()
@@ -206,16 +223,17 @@ public class SshUtil {
}
if (!conn.authenticateWithPublicKey(USER_NAME, PRIVATE_KEY_FILE, null)) {
- throw new ConnectionException("SSH Authentication (public key) failed for server ["
- + conn.getHostname() + "]");
+ return false;
}
+
+ return true;
} catch (IOException e) {
throw new ConnectionException("Exception during SSH authentication (public key) for server ["
+ conn.getHostname() + "]", e);
}
}
- private void authenticateWithPassword(Connection conn) {
+ private boolean authenticateWithPassword(Connection conn) {
try {
if (!supportsPasswordAuthentication(conn)) {
throw new ConnectionException("Password authentication not supported on [" + conn.getHostname()
@@ -223,9 +241,9 @@ public class SshUtil {
}
if (!conn.authenticateWithPassword(USER_NAME, DEFAULT_PASSWORD)) {
- throw new ConnectionException("SSH Authentication (password) failed for server ["
- + conn.getHostname() + "]");
+ return false;
}
+ return true;
} catch (IOException e) {
throw new ConnectionException("Exception during SSH authentication (password) for server ["
+ conn.getHostname() + "]", e);
@@ -241,12 +259,12 @@ public class SshUtil {
}
private synchronized Connection createConnection(String serverName) {
- Connection conn;
- conn = new Connection(serverName);
+ Connection conn = new Connection(serverName);
try {
conn.connect(null, sshConnectTimeout, sshKexTimeout);
} catch (IOException e) {
logger.error("Couldn't establish SSH connection with server [" + serverName + "]", e);
+ conn.close();
throw new ConnectionException("Exception while creating SSH connection with server [" + serverName + "]", e);
}
return conn;
@@ -382,11 +400,6 @@ public class SshUtil {
}
}
- private ProcessResult executeRemoteWithPubKey(String serverName, String command) {
- Connection connection = getConnection(serverName);
- return executeCommand(connection, command);
- }
-
/**
* Executes given command on remote machine using public key authentication
*
@@ -395,14 +408,8 @@ public class SshUtil {
* @return Result of remote execution
*/
public ProcessResult executeRemote(String serverName, String command) {
- try {
- logger.info("Executing command [" + command + "] on server [" + serverName + "] with public key authentication");
- return executeRemoteWithPubKey(serverName, command);
- } catch(ConnectionException e) {
- logger.warn("Couldn't execute command with public key authentication, will try with default password.", e);
- // Couldn't connect with public key. Try with default password.
- return executeRemoteWithPassword(serverName, command);
- }
+ logger.info("Executing command [" + command + "] on server [" + serverName + "]");
+ return executeCommand(getConnection(serverName), command);
}
/**
@@ -413,7 +420,7 @@ public class SshUtil {
*/
public boolean isPublicKeySetup(String serverName) {
try {
- getConnection(serverName);
+ getConnectionWithPubKey(serverName);
return true;
} catch (Exception e) {
return false;