airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject git commit: removing unnecessary static map in scp input/output hadnlers
Date Wed, 08 Oct 2014 18:36:15 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 3b63a2886 -> 532233f7b


removing unnecessary static map in scp input/output hadnlers


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

Branch: refs/heads/master
Commit: 532233f7b46e20ab66967740e58c289cc3dbe79b
Parents: 3b63a28
Author: lahiru <lahiru@apache.org>
Authored: Wed Oct 8 14:36:09 2014 -0400
Committer: lahiru <lahiru@apache.org>
Committed: Wed Oct 8 14:36:09 2014 -0400

----------------------------------------------------------------------
 .../ssh/handler/AdvancedSCPInputHandler.java    | 10 +++++++++
 .../ssh/handler/AdvancedSCPOutputHandler.java   |  7 +++++++
 .../airavata/gfac/ssh/util/GFACSSHUtils.java    | 22 ++++++++++++++------
 3 files changed, 33 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/532233f7/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPInputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPInputHandler.java
b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPInputHandler.java
index 9d94814..667d7b3 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPInputHandler.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPInputHandler.java
@@ -70,6 +70,7 @@ import java.util.*;
  */
 public class AdvancedSCPInputHandler extends AbstractRecoverableHandler {
     private static final Logger log = LoggerFactory.getLogger(AdvancedSCPInputHandler.class);
+    public static final String ADVANCED_SSH_AUTH = "advanced.ssh.auth";
 
     private String password = null;
 
@@ -120,6 +121,15 @@ public class AdvancedSCPInputHandler extends AbstractRecoverableHandler
{
                     log.error("Previously stored data " + pluginData + " is wrong so we continue
the operations");
                 }
             }
+
+            AuthenticationInfo authenticationInfo = null;
+            if (password != null) {
+                authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
+            } else {
+                authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath,
this.privateKeyPath,
+                        this.passPhrase);
+            }
+            jobExecutionContext.setProperty(ADVANCED_SSH_AUTH,authenticationInfo);
             if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)
== null) {
                 try {
                     GFACSSHUtils.addSecurityContext(jobExecutionContext);

http://git-wip-us.apache.org/repos/asf/airavata/blob/532233f7/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPOutputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPOutputHandler.java
b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPOutputHandler.java
index 1f16206..c147fd2 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPOutputHandler.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/handler/AdvancedSCPOutputHandler.java
@@ -99,6 +99,13 @@ public class AdvancedSCPOutputHandler extends AbstractHandler {
     @Override
     public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException
{
     	  Cluster pbsCluster = null;
+        AuthenticationInfo authenticationInfo = null;
+        if (password != null) {
+            authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
+        } else {
+            authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath,
this.privateKeyPath,
+                    this.passPhrase);
+        }
         try {
             if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)
== null) {
                 try {

http://git-wip-us.apache.org/repos/asf/airavata/blob/532233f7/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
index 646a375..ec309a0 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/ssh/util/GFACSSHUtils.java
@@ -61,6 +61,8 @@ public class GFACSSHUtils {
 
     public static int maxClusterCount = 5;
 
+    public static final String ADVANCED_SSH_AUTH = "advanced.ssh.auth";
+
 
     public static void addSecurityContext(JobExecutionContext jobExecutionContext) throws
GFacException, ApplicationSettingsException {
         HostDescription registeredHost = jobExecutionContext.getApplicationContext().getHostDescription();
@@ -74,15 +76,17 @@ public class GFACSSHUtils {
             requestData.setTokenId(credentialStoreToken);
 
             ServerInfo serverInfo = new ServerInfo(null, registeredHost.getType().getHostAddress());
+            AuthenticationInfo info = (AuthenticationInfo) jobExecutionContext.getProperty(ADVANCED_SSH_AUTH);
 
             Cluster pbsCluster = null;
             try {
                 TokenizedSSHAuthInfo tokenizedSSHAuthInfo = new TokenizedSSHAuthInfo(requestData);
                 String installedParentPath = ((HpcApplicationDeploymentType)
-                            jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType()).getInstalledParentPath();
-                if(installedParentPath== null) {
+                        jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType()).getInstalledParentPath();
+                if (installedParentPath == null) {
                     installedParentPath = "/";
                 }
+
                 SSHCredential credentials = tokenizedSSHAuthInfo.getCredentials();// this
is just a call to get and set credentials in to this object,data will be used
                 serverInfo.setUserName(credentials.getPortalUserName());
                 jobExecutionContext.getExperiment().setUserName(credentials.getPortalUserName());
@@ -102,7 +106,7 @@ public class GFACSSHUtils {
                             clusters.get(key).remove(i);
                             recreate = true;
                         }
-                        if(!recreate) {
+                        if (!recreate) {
                             try {
                                 pbsCluster.listDirectory("~/"); // its hard to trust isConnected
method, so we try to connect if it works we are good,else we recreate
                             } catch (Exception e) {
@@ -117,8 +121,14 @@ public class GFACSSHUtils {
                         recreate = true;
                     }
                     if (recreate) {
-                        pbsCluster = new PBSCluster(serverInfo, tokenizedSSHAuthInfo,
-                                CommonUtils.getPBSJobManager(installedParentPath));
+                        if (info != null) {
+                            pbsCluster = new PBSCluster(serverInfo, info,
+                                    CommonUtils.getPBSJobManager(installedParentPath));
+                            jobExecutionContext.setProperty(ADVANCED_SSH_AUTH,null); // some
other provider might fail
+                        } else {
+                            pbsCluster = new PBSCluster(serverInfo, tokenizedSSHAuthInfo,
+                                    CommonUtils.getPBSJobManager(installedParentPath));
+                        }
                         List<Cluster> pbsClusters = null;
                         if (!(clusters.containsKey(key))) {
                             pbsClusters = new ArrayList<Cluster>();
@@ -150,7 +160,7 @@ public class GFACSSHUtils {
         jobDescriptor.setStandardErrorFile(app.getStandardError());
         Random random = new Random();
         int i = random.nextInt(Integer.MAX_VALUE);
-        jobDescriptor.setJobName(String.valueOf(i+99999999));
+        jobDescriptor.setJobName(String.valueOf(i + 99999999));
         jobDescriptor.setWorkingDirectory(app.getStaticWorkingDirectory());
 
 


Mime
View raw message