airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1530070 - in /airavata/trunk/modules: distribution/airavata-server/src/main/resources/conf/ gfac-core/src/main/java/org/apache/airavata/gfac/context/security/ gfac-core/src/main/java/org/apache/airavata/gfac/handler/ gfac-core/src/main/jav...
Date Mon, 07 Oct 2013 21:20:10 GMT
Author: lahiru
Date: Mon Oct  7 21:20:10 2013
New Revision: 1530070

URL: http://svn.apache.org/r1530070
Log:
enabling ssh and gsissh in gfac-core.

Added:
    airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java
    airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java
    airavata/trunk/modules/gfac-core/src/test/resources/PBSTemplate.xslt
Modified:
    airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/gfac-config.xml
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/SSHSecurityContext.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPInputHandler.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
    airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTest.java
    airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml

Modified: airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/gfac-config.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/gfac-config.xml?rev=1530070&r1=1530069&r2=1530070&view=diff
==============================================================================
--- airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/gfac-config.xml
(original)
+++ airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/gfac-config.xml
Mon Oct  7 21:20:10 2013
@@ -24,7 +24,7 @@
             <Handler class="org.apache.airavata.gfac.handler.LocalDirectorySetupHandler"/>
         </InHandlers>
     </Provider>
-    <Provider class="org.apache.airavata.gfac.provider.impl.GramProvider" host="org.apache.airavata.schemas.gfac.impl.GlobusHostTypeImpl">
+    <Provider class="org.apache.airavata.gfac.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GlobusHostTypeImpl">
         <property name="name" value="value"/>
         <InHandlers>
             <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler">
@@ -78,4 +78,13 @@
             <Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/>
         </OutHandlers>
     </Provider>
+     <Provider class="org.apache.airavata.gfac.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl">
+         <InHandlers>
+            <Handler class="org.apache.airavata.gfac.handler.SCPDirectorySetupHandler"/>
+            <Handler class="org.apache.airavata.gfac.handler.SCPInputHandler"/>
+        </InHandlers>
+        <OutHandlers>
+            <!--Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/-->
+        </OutHandlers>
+    </Provider>
 </GFac>
\ No newline at end of file

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/SSHSecurityContext.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/SSHSecurityContext.java?rev=1530070&r1=1530069&r2=1530070&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/SSHSecurityContext.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/security/SSHSecurityContext.java
Mon Oct  7 21:20:10 2013
@@ -27,6 +27,7 @@ import net.schmizz.sshj.connection.chann
 import net.schmizz.sshj.userauth.keyprovider.KeyProvider;
 
 import org.apache.airavata.gfac.SecurityContext;
+import org.apache.airavata.gsi.ssh.api.Cluster;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,6 +45,8 @@ public class SSHSecurityContext implemen
 	private SSHClient sshClient;
 	private Session session;
 
+    Cluster pbsCluster;
+
 	public String getUsername() {
 		return username;
 	}
@@ -106,4 +109,12 @@ public class SSHSecurityContext implemen
 		}
 		return sshClient;
 	}
+
+    public void setPbsCluster(Cluster pbsCluster) {
+        this.pbsCluster = pbsCluster;
+    }
+
+    public Cluster getPbsCluster() {
+        return pbsCluster;
+    }
 }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java?rev=1530070&r1=1530069&r2=1530070&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java
Mon Oct  7 21:20:10 2013
@@ -33,6 +33,8 @@ import org.apache.airavata.gfac.Constant
 import org.apache.airavata.gfac.GFacException;
 import org.apache.airavata.gfac.context.JobExecutionContext;
 import org.apache.airavata.gfac.context.security.SSHSecurityContext;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
 import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,31 +52,13 @@ public class SCPDirectorySetupHandler im
 		ApplicationDeploymentDescriptionType app = context.getApplicationContext().getApplicationDeploymentDescription().getType();
 		Session session = null;
 		try {
-			session = securityContext.getSession(context.getApplicationContext().getHostDescription().getType().getHostAddress());
-
-			StringBuilder commandString = new StringBuilder();
-
-			commandString.append("mkdir -p ");
-			commandString.append(app.getScratchWorkingDirectory());
-			commandString.append(" ; ");
-			commandString.append("mkdir -p ");
-			commandString.append(app.getStaticWorkingDirectory());
-			commandString.append(" ; ");
-			commandString.append("mkdir -p ");
-			commandString.append(app.getInputDataDirectory());
-			commandString.append(" ; ");
-			commandString.append("mkdir -p ");
-			commandString.append(app.getOutputDataDirectory());
-
-			Command cmd = session.exec(commandString.toString());
-			cmd.join(Constants.COMMAND_EXECUTION_TIMEOUT, TimeUnit.SECONDS);
-		} catch (ConnectionException e) {
-			throw new GFacHandlerException(e.getMessage(), e, context);
-		} catch (TransportException e) {
-			throw new GFacHandlerException(e.getMessage(), e, context);
-		} catch (IOException e) {
-			throw new GFacHandlerException(e.getMessage(), e, context);
-		} finally {
+            Cluster pbsCluster = securityContext.getPbsCluster();
+            pbsCluster.makeDirectory(app.getScratchWorkingDirectory());
+            pbsCluster.makeDirectory(app.getInputDataDirectory());
+            pbsCluster.makeDirectory(app.getOutputDataDirectory());
+		} catch (SSHApiException e) {
+            throw new GFacHandlerException("Error executing the Handler: " + SCPDirectorySetupHandler.class,e);
 //To change body of catch statement use File | Settings | File Templates.
+        } finally {
 			securityContext.closeSession(session);
 		}
 	}

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPInputHandler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPInputHandler.java?rev=1530070&r1=1530069&r2=1530070&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPInputHandler.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPInputHandler.java
Mon Oct  7 21:20:10 2013
@@ -33,6 +33,8 @@ import org.apache.airavata.gfac.GFacExce
 import org.apache.airavata.gfac.context.JobExecutionContext;
 import org.apache.airavata.gfac.context.MessageContext;
 import org.apache.airavata.gfac.context.security.SSHSecurityContext;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
 import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
 import org.apache.airavata.schemas.gfac.URIArrayType;
 import org.apache.airavata.schemas.gfac.URIParameterType;
@@ -75,17 +77,21 @@ public class SCPInputHandler implements 
 	        }
 	        jobExecutionContext.setInMessageContext(inputNew);
 	}
-	 private static String stageInputFiles(JobExecutionContext context,String paramValue) throws
IOException,GFacException{
-		 ApplicationDeploymentDescriptionType app = context.getApplicationContext().getApplicationDeploymentDescription().getType();
 
-		 SSHSecurityContext securityContext = (SSHSecurityContext)context.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
-		 SCPFileTransfer fileTransfer = securityContext.getSSHClient().newSCPFileTransfer();
-		 String remoteFile = app.getInputDataDirectory() + File.separatorChar + paramValue;
-
-		 File inputFile = new File(paramValue);
-		 fileTransfer.upload(inputFile.getAbsolutePath(), remoteFile);
-		 return remoteFile;
-	 }
+    private static String stageInputFiles(JobExecutionContext context, String paramValue)
throws IOException, GFacException {
+        SSHSecurityContext securityContext = (SSHSecurityContext)context.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
+        Cluster pbsCluster = securityContext.getPbsCluster();
+        ApplicationDeploymentDescriptionType app = context.getApplicationContext().getApplicationDeploymentDescription().getType();
+        String remoteFile = app.getInputDataDirectory() + File.separatorChar + paramValue;
+
+        try {
+            return pbsCluster.scpTo(app.getInputDataDirectory(), remoteFile);
+        } catch (SSHApiException e) {
+            throw new GFacHandlerException("Error while input File Staging", context, e,
e.getLocalizedMessage());
+        } finally {
+            return null;
+        }
+    }
 
     public void initProperties(Map<String, String> properties) throws GFacHandlerException,
GFacException {
 

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java?rev=1530070&r1=1530069&r2=1530070&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
Mon Oct  7 21:20:10 2013
@@ -23,24 +23,17 @@ package org.apache.airavata.gfac.provide
 import org.apache.airavata.common.utils.StringUtil;
 import org.apache.airavata.commons.gfac.type.ActualParameter;
 import org.apache.airavata.commons.gfac.type.MappingFactory;
-import org.apache.airavata.gfac.Constants;
 import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.RequestData;
 import org.apache.airavata.gfac.context.JobExecutionContext;
 import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.context.security.SSHSecurityContext;
 import org.apache.airavata.gfac.notification.events.StartExecutionEvent;
 import org.apache.airavata.gfac.provider.GFacProvider;
 import org.apache.airavata.gfac.provider.GFacProviderException;
-import org.apache.airavata.gsi.ssh.api.AuthenticationInfo;
 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.job.JobDescriptor;
-import org.apache.airavata.gsi.ssh.impl.DefaultJobSubmissionListener;
-import org.apache.airavata.gsi.ssh.impl.MyProxyAuthenticationInfo;
 import org.apache.airavata.gsi.ssh.impl.PBSCluster;
-import org.apache.airavata.gsi.ssh.listener.JobSubmissionListener;
 import org.apache.airavata.schemas.gfac.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -65,17 +58,9 @@ public class GSISSHProvider implements G
         HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) jobExecutionContext.getApplicationContext().
                 getApplicationDeploymentDescription().getType();
         try {
-
-            GSISecurityContext gssCred = ((GSISecurityContext) jobExecutionContext.
-                    getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT));
-            RequestData requestData = gssCred.getRequestData();
-            ServerInfo serverInfo = new ServerInfo(requestData.getMyProxyUserName(), host.getHostAddress(),
22);
-            AuthenticationInfo authenticationInfo
-                    = new MyProxyAuthenticationInfo(requestData.getMyProxyUserName(), requestData.getMyProxyPassword(),
requestData.getMyProxyServerUrl(),
-                    7512, 17280000, System.getProperty(Constants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY));
-
+            SSHSecurityContext securityContext = (SSHSecurityContext) jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
+            Cluster cluster = securityContext.getPbsCluster();
             // This installed path is a mandetory field, because this could change based
on the computing resource
-            Cluster cluster = new PBSCluster(serverInfo, authenticationInfo,host.getInstalledParentPath());
             JobDescriptor jobDescriptor = new JobDescriptor();
             jobDescriptor.setWorkingDirectory(app.getScratchWorkingDirectory());
             jobDescriptor.setShellName("/bin/bash");
@@ -89,10 +74,15 @@ public class GSISSHProvider implements G
             jobDescriptor.setStandardErrorFile(app.getStandardError());
             jobDescriptor.setNodes(app.getNodeCount());
             jobDescriptor.setProcessesPerNode(app.getProcessorsPerNode());
-            jobDescriptor.setMaxWallTime(maxWallTimeCalculator(app.getMaxWallTime()));
-            jobDescriptor.setAcountString(app.getProjectAccount().getProjectAccountNumber());
-            jobDescriptor.setQueueName(app.getQueue().getQueueName());
-            jobDescriptor.setOwner(requestData.getMyProxyUserName());
+            jobDescriptor.setMaxWallTime(String.valueOf(app.getMaxWallTime()));
+            jobDescriptor.setJobSubmitter(app.getJobSubmitterCommand());
+            if (app.getProjectAccount() != null) {
+                jobDescriptor.setAcountString(app.getProjectAccount().getProjectAccountNumber());
+            }
+            if (app.getQueue() != null) {
+                jobDescriptor.setQueueName(app.getQueue().getQueueName());
+            }
+            jobDescriptor.setOwner(((PBSCluster) cluster).getServerInfo().getUserName());
             List<String> inputValues = new ArrayList<String>();
             MessageContext input = jobExecutionContext.getInMessageContext();
             Map<String, Object> inputs = input.getParameters();
@@ -118,6 +108,7 @@ public class GSISSHProvider implements G
             }
             jobDescriptor.setInputValues(inputValues);
 
+            System.out.println(jobDescriptor.toXML());
             cluster.submitBatchJob(jobDescriptor);
         } catch (SSHApiException e) {
             String error = "Error submitting the job to host " + host.getHostAddress() +
e.getMessage();

Added: airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java?rev=1530070&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java
(added)
+++ airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java
Mon Oct  7 21:20:10 2013
@@ -0,0 +1,204 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.core.gfac.services.impl;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacAPI;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.SecurityContext;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.SSHSecurityContext;
+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.schemas.gfac.*;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class BigRed2Test {
+    private JobExecutionContext jobExecutionContext;
+
+    private static final String hostAddress = "bigred2";
+    private static final String hostName = "bigred2.uits.iu.edu";
+    private static final String userName = "lginnali";
+    private static final String password = "";
+
+    @Before
+    public void setUp() throws Exception {
+        URL resource = GramProviderTest.class.getClassLoader().getResource("gfac-config.xml");
+        assert resource != null;
+        System.out.println(resource.getFile());
+        GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()),
null, null);
+
+//        gFacConfiguration.setMyProxyLifeCycle(3600);
+//        gFacConfiguration.setMyProxyServer("myproxy.teragrid.org");
+//        gFacConfiguration.setMyProxyUser("*****");
+//        gFacConfiguration.setMyProxyPassphrase("*****");
+//        gFacConfiguration.setTrustedCertLocation("./certificates");
+//        //have to set InFlwo Handlers and outFlowHandlers
+//        gFacConfiguration.setInHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GramDirectorySetupHandler","org.apache.airavata.gfac.handler.GridFTPInputHandler"}));
+//        gFacConfiguration.setOutHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GridFTPOutputHandler"}));
+
+        /*
+        * Host
+        */
+        HostDescription host = new HostDescription(GsisshHostType.type);
+        host.getType().setHostAddress(hostAddress);
+        host.getType().setHostName(hostName);
+        ((GsisshHostType) host.getType()).setInstalledParentPath("/opt/torque/torque-4.2.3.1/bin/");
+        /*
+        * App
+        */
+        ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
+        HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc.getType();
+        ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+        name.setStringValue("EchoLocal");
+        app.setApplicationName(name);
+
+        app.setCpuCount(1);
+        app.setJobType(JobTypeType.SERIAL);
+        app.setNodeCount(1);
+        app.setProcessorsPerNode(1);
+
+        /*
+        * Use bat file if it is compiled on Windows
+        */
+        app.setExecutableLocation("/bin/echo");
+
+        /*
+        * Default tmp location
+        */
+        String tempDir = "~/";
+        String date = (new Date()).toString();
+        date = date.replaceAll(" ", "_");
+        date = date.replaceAll(":", "_");
+
+        tempDir = tempDir + File.separator
+                + "SimpleEcho" + "_" + date + "_" + UUID.randomUUID();
+
+        System.out.println(tempDir);
+        app.setScratchWorkingDirectory(tempDir);
+        app.setStaticWorkingDirectory(tempDir);
+        app.setInputDataDirectory(tempDir + File.separator + "inputData");
+        app.setOutputDataDirectory(tempDir + File.separator + "outputData");
+        app.setStandardOutput(tempDir + File.separator + app.getApplicationName().getStringValue()
+ ".stdout");
+        app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue()
+ ".stderr");
+        app.setMaxWallTime(5);
+        app.setJobSubmitterCommand("aprun -n 1");
+
+
+        /*
+        * Service
+        */
+        ServiceDescription serv = new ServiceDescription();
+        serv.getType().setName("SimpleEcho");
+
+        List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+
+        InputParameterType input = InputParameterType.Factory.newInstance();
+        input.setParameterName("echo_input");
+        input.setParameterType(StringParameterType.Factory.newInstance());
+        inputList.add(input);
+
+        InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
+
+                .size()]);
+        List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+        OutputParameterType output = OutputParameterType.Factory.newInstance();
+        output.setParameterName("echo_output");
+        output.setParameterType(StringParameterType.Factory.newInstance());
+        outputList.add(output);
+
+        OutputParameterType[] outputParamList = outputList
+                .toArray(new OutputParameterType[outputList.size()]);
+
+        serv.getType().setInputParametersArray(inputParamList);
+        serv.getType().setOutputParametersArray(outputParamList);
+
+        jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
+        // Adding security context
+        jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext(host));
+        ApplicationContext applicationContext = new ApplicationContext();
+        jobExecutionContext.setApplicationContext(applicationContext);
+        applicationContext.setServiceDescription(serv);
+        applicationContext.setApplicationDeploymentDescription(appDesc);
+        applicationContext.setHostDescription(host);
+
+        MessageContext inMessage = new MessageContext();
+        ActualParameter echo_input = new ActualParameter();
+        ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
+        inMessage.addParameter("echo_input", echo_input);
+
+
+        jobExecutionContext.setInMessageContext(inMessage);
+
+        MessageContext outMessage = new MessageContext();
+        ActualParameter echo_out = new ActualParameter();
+//		((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
+        outMessage.addParameter("echo_output", echo_out);
+
+        jobExecutionContext.setOutMessageContext(outMessage);
+
+    }
+
+    private SecurityContext getSecurityContext(HostDescription host) {
+        AuthenticationInfo authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
+        // Server info
+        ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
+
+        Cluster pbsCluster = null;
+        try {
+             pbsCluster = new PBSCluster(serverInfo, authenticationInfo,
+                     ((GsisshHostType)host.getType()).getInstalledParentPath());
+        } catch (SSHApiException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
+        }
+
+
+        SSHSecurityContext sshSecurityContext = new SSHSecurityContext();
+        sshSecurityContext.setPbsCluster(pbsCluster);
+        sshSecurityContext.setUsername(userName);
+        return sshSecurityContext;
+    }
+
+    @Test
+    public void testGramProvider() throws GFacException {
+        GFacAPI gFacAPI = new GFacAPI();
+        gFacAPI.submitJob(jobExecutionContext);
+    }
+
+}

Added: airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java?rev=1530070&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java
(added)
+++ airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java
Mon Oct  7 21:20:10 2013
@@ -0,0 +1,208 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.core.gfac.services.impl;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacAPI;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.SecurityContext;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.SSHSecurityContext;
+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.GSIAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.impl.PBSCluster;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.apache.airavata.schemas.gfac.*;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class GSISSHProviderTest {
+    private JobExecutionContext jobExecutionContext;
+
+    //FIXME: move job properties to configuration file
+    private static final String hostAddress = "trestles.sdsc.edu";
+    private static final String hostName = "trestles";
+    private static final String myProxyUserName = "ogce";
+    private static final String myProxyPassword = "";
+    private static final String certificateLocation = "/Users/lahirugunathilake/Downloads/certificates";
+
+    @Before
+    public void setUp() throws Exception {
+        URL resource = GSISSHProviderTest.class.getClassLoader().getResource("gfac-config.xml");
+        assert resource != null;
+        System.out.println(resource.getFile());
+        GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()),
null, null);
+
+//        gFacConfiguration.setMyProxyLifeCycle(3600);
+//        gFacConfiguration.setMyProxyServer("myproxy.teragrid.org");
+//        gFacConfiguration.setMyProxyUser("*****");
+//        gFacConfiguration.setMyProxyPassphrase("*****");
+//        gFacConfiguration.setTrustedCertLocation("./certificates");
+//        //have to set InFlwo Handlers and outFlowHandlers
+//        gFacConfiguration.setInHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GramDirectorySetupHandler","org.apache.airavata.gfac.handler.GridFTPInputHandler"}));
+//        gFacConfiguration.setOutHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GridFTPOutputHandler"}));
+
+        /*
+        * Host
+        */
+        HostDescription host = new HostDescription(GsisshHostType.type);
+        host.getType().setHostAddress(hostAddress);
+        host.getType().setHostName(hostName);
+        ((GsisshHostType) host.getType()).setInstalledParentPath("/opt/torque/bin/");
+        /*
+        * App
+        */
+        ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
+        HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc.getType();
+        ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+        name.setStringValue("EchoLocal");
+        app.setApplicationName(name);
+        ProjectAccountType projectAccountType = app.addNewProjectAccount();
+        projectAccountType.setProjectAccountNumber("sds128");
+
+        QueueType queueType = app.addNewQueue();
+        queueType.setQueueName("normal");
+
+        app.setCpuCount(1);
+        app.setJobType(JobTypeType.SERIAL);
+        app.setNodeCount(1);
+        app.setProcessorsPerNode(1);
+
+        /*
+        * Use bat file if it is compiled on Windows
+        */
+        app.setExecutableLocation("/bin/echo");
+
+        /*
+        * Default tmp location
+        */
+        String tempDir = "/home/ogce/scratch/";
+        String date = (new Date()).toString();
+        date = date.replaceAll(" ", "_");
+        date = date.replaceAll(":", "_");
+
+        tempDir = tempDir + File.separator
+                + "SimpleEcho" + "_" + date + "_" + UUID.randomUUID();
+
+        System.out.println(tempDir);
+        app.setScratchWorkingDirectory(tempDir);
+        app.setStaticWorkingDirectory(tempDir);
+        app.setInputDataDirectory(tempDir + File.separator + "inputData");
+        app.setOutputDataDirectory(tempDir + File.separator + "outputData");
+        app.setStandardOutput(tempDir + File.separator + app.getApplicationName().getStringValue()
+ ".stdout");
+        app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue()
+ ".stderr");
+        app.setMaxWallTime(5);
+
+
+        /*
+        * Service
+        */
+        ServiceDescription serv = new ServiceDescription();
+        serv.getType().setName("SimpleEcho");
+
+        List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+
+        InputParameterType input = InputParameterType.Factory.newInstance();
+        input.setParameterName("echo_input");
+        input.setParameterType(StringParameterType.Factory.newInstance());
+        inputList.add(input);
+
+        InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
+
+                .size()]);
+        List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+        OutputParameterType output = OutputParameterType.Factory.newInstance();
+        output.setParameterName("echo_output");
+        output.setParameterType(StringParameterType.Factory.newInstance());
+        outputList.add(output);
+
+        OutputParameterType[] outputParamList = outputList
+                .toArray(new OutputParameterType[outputList.size()]);
+
+        serv.getType().setInputParametersArray(inputParamList);
+        serv.getType().setOutputParametersArray(outputParamList);
+
+        jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
+        // Adding security context
+        jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext());
+        ApplicationContext applicationContext = new ApplicationContext();
+        jobExecutionContext.setApplicationContext(applicationContext);
+        applicationContext.setServiceDescription(serv);
+        applicationContext.setApplicationDeploymentDescription(appDesc);
+        applicationContext.setHostDescription(host);
+
+        MessageContext inMessage = new MessageContext();
+        ActualParameter echo_input = new ActualParameter();
+        ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
+        inMessage.addParameter("echo_input", echo_input);
+
+
+        jobExecutionContext.setInMessageContext(inMessage);
+
+        MessageContext outMessage = new MessageContext();
+        ActualParameter echo_out = new ActualParameter();
+//		((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
+        outMessage.addParameter("echo_output", echo_out);
+
+        jobExecutionContext.setOutMessageContext(outMessage);
+
+    }
+
+    private SecurityContext getSecurityContext() {
+        GSIAuthenticationInfo authenticationInfo
+                = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+                7512, 17280000, certificateLocation);
+
+        // Server info
+        ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
+        Cluster pbsCluster = null;
+        try {
+            pbsCluster = new PBSCluster(serverInfo, authenticationInfo, "/opt/torque/bin/");
+        } catch (SSHApiException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
+        }
+        SSHSecurityContext sshSecurityContext = new SSHSecurityContext();
+        sshSecurityContext.setPbsCluster(pbsCluster);
+        sshSecurityContext.setUsername(myProxyUserName);
+        return sshSecurityContext;
+    }
+    @Test
+    public void testGramProvider() throws GFacException {
+        GFacAPI gFacAPI = new GFacAPI();
+        gFacAPI.submitJob(jobExecutionContext);
+    }
+
+}

Modified: airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTest.java?rev=1530070&r1=1530069&r2=1530070&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTest.java
(original)
+++ airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTest.java
Mon Oct  7 21:20:10 2013
@@ -60,8 +60,8 @@ public class SSHProviderTest {
         //have to set InFlwo Handlers and outFlowHandlers
         ApplicationContext applicationContext = new ApplicationContext();
         HostDescription host = new HostDescription(SSHHostType.type);
-        host.getType().setHostName("gw85.iu.xsede.org");
-        host.getType().setHostAddress("gw85.iu.xsede.org");
+        host.getType().setHostName("bigred");
+        host.getType().setHostAddress("bigred2.uits.iu.edu");
         applicationContext.setHostDescription(host);
         /*
            * App
@@ -156,9 +156,9 @@ public class SSHProviderTest {
 
 	private SSHSecurityContext getSecurityContext() {
 		SSHSecurityContext context = new SSHSecurityContext();
-        context.setUsername("*****");
+        context.setUsername("lginnali");
         context.setPrivateKeyLoc("~/.ssh/id_dsa");
-        context.setKeyPass("*****");
+        context.setKeyPass("i want to be free");
 		return context;
 	}
 

Added: airavata/trunk/modules/gfac-core/src/test/resources/PBSTemplate.xslt
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/resources/PBSTemplate.xslt?rev=1530070&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/resources/PBSTemplate.xslt (added)
+++ airavata/trunk/modules/gfac-core/src/test/resources/PBSTemplate.xslt Mon Oct  7 21:20:10
2013
@@ -0,0 +1,73 @@
+<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license
agreements. See the NOTICE file
+	distributed with this work for additional information regarding copyright ownership. The
ASF licenses this file to you under
+	the Apache License, Version 2.0 (theÏ "License"); you may not use this file except in
compliance with the License. You may
+	obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to
+	in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF
+	ANY ~ KIND, either express or implied. See the License for the specific language governing
permissions and limitations under
+	the License. -->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://airavata.apache.org/gsi/ssh/2012/12">
+<xsl:output method="text" />
+<xsl:template match="/ns:JobDescriptor">
+#! /bin/sh
+# PBS batch job script built by Globus job manager
+#   <xsl:choose>
+    <xsl:when test="ns:shellName">
+##PBS -S <xsl:value-of select="ns:shellName"/>
+    </xsl:when></xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:queueName">
+#PBS -q <xsl:value-of select="ns:queueName"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:mailOptions">
+#PBS -m <xsl:value-of select="ns:mailOptions"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+<xsl:when test="ns:acountString">
+#PBS -A <xsl:value-of select="ns:acountString"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:maxWallTime">
+#PBS -l walltime=<xsl:value-of select="ns:maxWallTime"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:standardOutFile">
+#PBS -o <xsl:value-of select="ns:standardOutFile"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:standardOutFile">
+#PBS -e <xsl:value-of select="ns:standardErrorFile"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="(ns:nodes) and (ns:processesPerNode)">
+#PBS -l nodes=<xsl:value-of select="ns:nodes"/>:ppn=<xsl:value-of select="ns:processesPerNode"/>
+<xsl:text>&#xa;</xsl:text>
+    </xsl:when>
+    </xsl:choose>
+<xsl:for-each select="ns:exports/ns:name">
+<xsl:value-of select="."/>=<xsl:value-of select="./@value"/><xsl:text>&#xa;</xsl:text>
+export<xsl:text>   </xsl:text><xsl:value-of select="."/>
+<xsl:text>&#xa;</xsl:text>
+</xsl:for-each>
+<xsl:for-each select="ns:preJobCommands/ns:command">
+      <xsl:value-of select="."/><xsl:text>   </xsl:text>
+    </xsl:for-each>
+cd <xsl:text>   </xsl:text><xsl:value-of select="ns:workingDirectory"/><xsl:text>&#xa;</xsl:text>
+    <xsl:choose><xsl:when test="ns:jobSubmitterCommand">
+<xsl:value-of select="ns:jobSubmitterCommand"/><xsl:text>   </xsl:text></xsl:when></xsl:choose><xsl:value-of
select="ns:executablePath"/><xsl:text>   </xsl:text>
+<xsl:for-each select="ns:inputs/ns:input">
+      <xsl:value-of select="."/><xsl:text>   </xsl:text>
+    </xsl:for-each>
+<xsl:for-each select="ns:postJobCommands/ns:command">
+      <xsl:value-of select="."/><xsl:text>   </xsl:text>
+</xsl:for-each>
+
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file

Modified: airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml?rev=1530070&r1=1530069&r2=1530070&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml (original)
+++ airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml Mon Oct  7 21:20:10
2013
@@ -78,4 +78,13 @@
             <Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/>
         </OutHandlers>
     </Provider>
+     <Provider class="org.apache.airavata.gfac.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl">
+         <InHandlers>
+            <Handler class="org.apache.airavata.gfac.handler.SCPDirectorySetupHandler"/>
+            <Handler class="org.apache.airavata.gfac.handler.SCPInputHandler"/>
+        </InHandlers>
+        <OutHandlers>
+            <!--Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/-->
+        </OutHandlers>
+    </Provider>
 </GFac>
\ No newline at end of file



Mime
View raw message