You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2015/12/14 20:06:55 UTC

airavata git commit: Read login user name from gateway computer resouce preferences

Repository: airavata
Updated Branches:
  refs/heads/master 150aa8014 -> bd457c2d5


Read login user name from gateway computer resouce preferences


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/bd457c2d
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/bd457c2d
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/bd457c2d

Branch: refs/heads/master
Commit: bd457c2d5b474aead5a81add3bfa26f0f65db30b
Parents: 150aa80
Author: Shameera Rathnayaka <sh...@gmail.com>
Authored: Mon Dec 14 14:06:50 2015 -0500
Committer: Shameera Rathnayaka <sh...@gmail.com>
Committed: Mon Dec 14 14:06:50 2015 -0500

----------------------------------------------------------------------
 .../org/apache/airavata/gfac/impl/Factory.java    | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/bd457c2d/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
index 8b3fa27..328ddd3 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
@@ -209,6 +209,7 @@ public abstract class Factory {
         JobSubmissionProtocol jobSubmissionProtocol = processContext.getJobSubmissionProtocol();
         String key = jobSubmissionProtocol.name() + ":" + computeResourceId;
 		RemoteCluster remoteCluster = remoteClusterMap.get(key);
+        String loginUserName = processContext.getComputeResourcePreference().getLoginUserName();
         if (remoteCluster == null) {
             JobManagerConfiguration jobManagerConfiguration = getJobManagerConfiguration(processContext.getResourceJobManager());
             if (jobSubmissionProtocol == JobSubmissionProtocol.LOCAL ||
@@ -216,7 +217,7 @@ public abstract class Factory {
                 remoteCluster = new LocalRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration, null);
             } else if (jobSubmissionProtocol == JobSubmissionProtocol.SSH ||
                     jobSubmissionProtocol == JobSubmissionProtocol.SSH_FORK) {
-                AuthenticationInfo authenticationInfo = getSSHKeyAuthentication();
+                AuthenticationInfo authenticationInfo = getSSHKeyAuthentication(loginUserName);
                 remoteCluster = new HPCRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration, authenticationInfo);
             }
             remoteClusterMap.put(key, remoteCluster);
@@ -230,13 +231,14 @@ public abstract class Factory {
         String computeResourceId = processContext.getComputeResourceId();
         DataMovementProtocol dataMovementProtocol = processContext.getDataMovementProtocol();
         String key = dataMovementProtocol.name() + ":" + computeResourceId;
+        String loginUserName = processContext.getComputeResourcePreference().getLoginUserName();
         RemoteCluster remoteCluster = remoteClusterMap.get(key);
         if (remoteCluster == null) {
             JobManagerConfiguration jobManagerConfiguration = getJobManagerConfiguration(processContext.getResourceJobManager());
             if (dataMovementProtocol == DataMovementProtocol.LOCAL) {
                 remoteCluster = new LocalRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration, null);
             } else if (dataMovementProtocol == DataMovementProtocol.SCP) {
-                AuthenticationInfo authenticationInfo = getSSHKeyAuthentication();
+                AuthenticationInfo authenticationInfo = getSSHKeyAuthentication(loginUserName);
                 remoteCluster = new HPCRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration, authenticationInfo);
             }
 
@@ -245,17 +247,21 @@ public abstract class Factory {
         return remoteCluster;
     }
 
-	private static SSHKeyAuthentication getSSHKeyAuthentication() throws ApplicationSettingsException {
+	private static SSHKeyAuthentication getSSHKeyAuthentication(String loginUserName) throws ApplicationSettingsException {
 		SSHKeyAuthentication sshKA = new SSHKeyAuthentication();
-		sshKA.setUserName(ServerSettings.getSetting("ssh.username"));
+        if (loginUserName != null && !loginUserName.isEmpty()) {
+            sshKA.setUserName(loginUserName);
+        } else {
+            sshKA.setUserName(ServerSettings.getSetting("ssh.username"));
+        }
 		sshKA.setPassphrase(ServerSettings.getSetting("ssh.keypass"));
 		sshKA.setPrivateKeyFilePath(ServerSettings.getSetting("ssh.private.key"));
 		sshKA.setPublicKeyFilePath(ServerSettings.getSetting("ssh.public.key"));
 		sshKA.setStrictHostKeyChecking(ServerSettings.getSetting("ssh.strict.hostKey.checking", "no"));
 		sshKA.setKnownHostsFilePath(ServerSettings.getSetting("ssh.known.hosts.file", null));
 		if (sshKA.getStrictHostKeyChecking().equals("yes") && sshKA.getKnownHostsFilePath() == null) {
-			throw new ApplicationSettingsException("If ssh scrict hostky checking property is set to yes, you must " +
-					"provid known host file path");
+			throw new ApplicationSettingsException("If ssh strict hostkey checking property is set to yes, you must " +
+					"provide known host file path");
 		}
 		return sshKA;
 	}