airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject [1/2] git commit: fixing AIRAVATA-1488
Date Thu, 30 Oct 2014 18:19:37 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 8b82bee96 -> a728bf212


fixing AIRAVATA-1488


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

Branch: refs/heads/master
Commit: 99e47f16b20c80f5338eabde53cf9a0c9f46e5d4
Parents: b376951
Author: lahiru <lahiru@apache.org>
Authored: Thu Oct 30 14:19:11 2014 -0400
Committer: lahiru <lahiru@apache.org>
Committed: Thu Oct 30 14:19:11 2014 -0400

----------------------------------------------------------------------
 .../ssh/handler/AdvancedSCPInputHandler.java    | 24 +++----------
 .../ssh/handler/AdvancedSCPOutputHandler.java   | 38 +++++++-------------
 .../airavata/gfac/ssh/util/GFACSSHUtils.java    | 34 ++++++++++++++++++
 3 files changed, 51 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/99e47f16/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 de4dd41..a8c3ad0 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
@@ -131,23 +131,7 @@ public class AdvancedSCPInputHandler extends AbstractRecoverableHandler
{
                 authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath,
this.privateKeyPath,
                         this.passPhrase);
             }
-            ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
-            String key = this.userName + this.hostName + DEFAULT_SSH_PORT;
-            SSHAuthWrapper sshAuthWrapper = new SSHAuthWrapper(serverInfo, authenticationInfo,
key);
-            if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT+key)
== null) {
-                try {
-                    GFACSSHUtils.addSecurityContext(jobExecutionContext,sshAuthWrapper);
-                } catch (ApplicationSettingsException e) {
-                    log.error(e.getMessage());
-                    try {
-                        GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(),
CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
-                    } catch (GFacException e1) {
-                        log.error(e1.getLocalizedMessage());
-                    }
-                    throw new GFacHandlerException("Error while creating SSHSecurityContext",
e, e.getLocalizedMessage());
-                }
-            }
-            pbsCluster = ((SSHSecurityContext)jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)).getPbsCluster();
+
             // Server info
             String parentPath = inputPath + File.separator + jobExecutionContext.getExperimentID()
+ File.separator + jobExecutionContext.getTaskData().getTaskID();
             if (index < oldIndex) {
@@ -172,10 +156,12 @@ public class AdvancedSCPInputHandler extends AbstractRecoverableHandler
{
                 if ("URI".equals(actualParameter.getType().getType().toString())) {
                     try {
                         URL file = new URL(paramValue);
-                        this.userName = file.getUserInfo();
-                        this.hostName = file.getHost();
+                        GFACSSHUtils.prepareSecurityContext(jobExecutionContext, authenticationInfo,
file.getUserInfo(), file.getHost(), DEFAULT_SSH_PORT);
+                        pbsCluster = ((SSHSecurityContext)jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)).getPbsCluster();
                         paramValue = file.getPath();
                     } catch (MalformedURLException e) {
+                        GFACSSHUtils.prepareSecurityContext(jobExecutionContext, authenticationInfo,
this.userName, this.hostName, DEFAULT_SSH_PORT);
+                        pbsCluster = ((SSHSecurityContext)jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)).getPbsCluster();
                         log.error(e.getLocalizedMessage(), e);
                     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/99e47f16/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 aed6e9f..dfd84de 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
@@ -35,7 +35,6 @@ import org.apache.airavata.gsi.ssh.api.Cluster;
 import org.apache.airavata.gsi.ssh.api.SSHApiException;
 import org.apache.airavata.gsi.ssh.api.ServerInfo;
 import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
-import org.apache.airavata.gsi.ssh.impl.PBSCluster;
 import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPasswordAuthenticationInfo;
 import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPublicKeyFileAuthentication;
 import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
@@ -110,24 +109,7 @@ public class AdvancedSCPOutputHandler extends AbstractHandler {
             authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath,
this.privateKeyPath,
                     this.passPhrase);
         }
-        ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
-        String key = this.userName + this.hostName + DEFAULT_SSH_PORT;
-        SSHAuthWrapper sshAuthWrapper = new SSHAuthWrapper(serverInfo, authenticationInfo,
key);
         try {
-            if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT+key)
== null) {
-                try {
-                    GFACSSHUtils.addSecurityContext(jobExecutionContext,sshAuthWrapper);
-                } catch (ApplicationSettingsException e) {
-                    log.error(e.getMessage());
-                    try {
-         				GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT,
ErrorCategory.AIRAVATA_INTERNAL_ERROR);
-         			} catch (GFacException e1) {
-         				 log.error(e1.getLocalizedMessage());
-         			}
-                    throw new GFacHandlerException("Error while creating SSHSecurityContext",
e, e.getLocalizedMessage());
-                }
-            }
-            pbsCluster = ((SSHSecurityContext)jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)).getPbsCluster();
             ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
                     .getApplicationDeploymentDescription().getType();
             String standardError = app.getStandardError();
@@ -135,15 +117,17 @@ public class AdvancedSCPOutputHandler extends AbstractHandler {
             super.invoke(jobExecutionContext);
             // Server info
             if(jobExecutionContext.getTaskData().getAdvancedOutputDataHandling() != null
&& jobExecutionContext.getTaskData().getAdvancedOutputDataHandling().getOutputDataDir()
!= null){
-            	try{
-            	URL outputPathURL = new URL(jobExecutionContext.getTaskData().getAdvancedOutputDataHandling().getOutputDataDir());
-            	this.userName = outputPathURL.getUserInfo();
-            	this.hostName = outputPathURL.getHost();
-            	outputPath = outputPathURL.getPath();
-            	} catch (MalformedURLException e) {
-					log.error(e.getLocalizedMessage(),e);
-				}
+                try{
+                    URL outputPathURL = new URL(jobExecutionContext.getTaskData().getAdvancedOutputDataHandling().getOutputDataDir());
+                    this.userName = outputPathURL.getUserInfo();
+                    this.hostName = outputPathURL.getHost();
+                    outputPath = outputPathURL.getPath();
+                } catch (MalformedURLException e) {
+                    log.error(e.getLocalizedMessage(),e);
+                }
             }
+            String key = GFACSSHUtils.prepareSecurityContext(jobExecutionContext, authenticationInfo,
this.userName, this.hostName, DEFAULT_SSH_PORT);
+            pbsCluster = ((SSHSecurityContext)jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT+key)).getPbsCluster();
             if(jobExecutionContext.getTaskData().getAdvancedOutputDataHandling() != null
&& !jobExecutionContext.getTaskData().getAdvancedOutputDataHandling().isPersistOutputData()){
             outputPath = outputPath + File.separator + jobExecutionContext.getExperimentID()
+ "-" + jobExecutionContext.getTaskData().getTaskID()
                     + File.separator;
@@ -190,4 +174,6 @@ public class AdvancedSCPOutputHandler extends AbstractHandler {
         	throw new GFacHandlerException(e);
         }
     }
+
+
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/99e47f16/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 94f07b1..ad2731a 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
@@ -32,6 +32,7 @@ import org.apache.airavata.gfac.GFacException;
 import org.apache.airavata.gfac.RequestData;
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
 import org.apache.airavata.gfac.core.context.MessageContext;
+import org.apache.airavata.gfac.core.handler.GFacHandlerException;
 import org.apache.airavata.gfac.core.utils.GFacUtils;
 import org.apache.airavata.gfac.ssh.context.SSHAuthWrapper;
 import org.apache.airavata.gfac.ssh.security.SSHSecurityContext;
@@ -48,6 +49,8 @@ import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPasswordAuthentica
 import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPublicKeyFileAuthentication;
 import org.apache.airavata.gsi.ssh.util.CommonUtils;
 import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling;
+import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
+import org.apache.airavata.model.workspace.experiment.ErrorCategory;
 import org.apache.airavata.model.workspace.experiment.TaskDetails;
 import org.apache.airavata.schemas.gfac.*;
 import org.slf4j.Logger;
@@ -294,4 +297,35 @@ public class GFACSSHUtils {
         return jobDescriptor;
     }
 
+    /**
+     * This method can be used to set the Security Context if its not set and later use it
in other places
+     * @param jobExecutionContext
+     * @param authenticationInfo
+     * @param userName
+     * @param hostName
+     * @param port
+     * @return
+     * @throws GFacException
+     */
+    public static String prepareSecurityContext(JobExecutionContext jobExecutionContext,
AuthenticationInfo authenticationInfo
+            , String userName, String hostName, int port) throws GFacException {
+        ServerInfo serverInfo = new ServerInfo(userName, hostName);
+        String key = userName+hostName+port;
+        SSHAuthWrapper sshAuthWrapper = new SSHAuthWrapper(serverInfo, authenticationInfo,
key);
+        if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT+key)
== null) {
+            try {
+                GFACSSHUtils.addSecurityContext(jobExecutionContext, sshAuthWrapper);
+            } catch (ApplicationSettingsException e) {
+                logger.error(e.getMessage());
+                try {
+                    GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(),
CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
+                } catch (GFacException e1) {
+                    logger.error(e1.getLocalizedMessage());
+                }
+                throw new GFacHandlerException("Error while creating SSHSecurityContext",
e, e.getLocalizedMessage());
+            }
+        }
+        return key;
+    }
+
 }


Mime
View raw message