airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject [1/3] Implementing slurm support - AIRAVATA-1057
Date Thu, 06 Mar 2014 23:14:41 GMT
Repository: airavata
Updated Branches:
  refs/heads/master f986e09c1 -> 532f2691e


http://git-wip-us.apache.org/repos/asf/airavata/blob/b3581061/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAbstractCluster.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAbstractCluster.java b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAbstractCluster.java
new file mode 100644
index 0000000..ca9094e
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAbstractCluster.java
@@ -0,0 +1,417 @@
+/*
+ *
+ * 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.gsi.ssh.impl;
+
+import com.jcraft.jsch.*;
+import org.apache.airavata.gsi.ssh.api.*;
+import org.apache.airavata.gsi.ssh.api.authentication.*;
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
+import org.apache.airavata.gsi.ssh.api.job.JobManagerConfiguration;
+import org.apache.airavata.gsi.ssh.api.job.OutputParser;
+import org.apache.airavata.gsi.ssh.config.ConfigReader;
+import org.apache.airavata.gsi.ssh.jsch.ExtendedJSch;
+import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.gsi.ssh.util.SSHAPIUIKeyboardInteractive;
+import org.apache.airavata.gsi.ssh.util.SSHKeyPasswordHandler;
+import org.apache.airavata.gsi.ssh.util.SSHUtils;
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.transform.*;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URL;
+import java.security.SecureRandom;
+
+public class GSISSHAbstractCluster implements Cluster {
+    static {
+        JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gsi.ssh.GSSContextX509");
+        JSch.setConfig("userauth.gssapi-with-mic", "com.jcraft.jsch.UserAuthGSSAPIWithMICGSSCredentials");
+
+    }
+
+    private static final Logger log = LoggerFactory.getLogger(GSISSHAbstractCluster.class);
+    public static final String X509_CERT_DIR = "X509_CERT_DIR";
+    public static final String SSH_SESSION_TIMEOUT = "ssh.session.timeout";
+
+    public JobManagerConfiguration jobManagerConfiguration;
+
+    private ServerInfo serverInfo;
+
+    private AuthenticationInfo authenticationInfo;
+
+    private Session session;
+
+    private ConfigReader configReader;
+
+
+    public GSISSHAbstractCluster(ServerInfo serverInfo, AuthenticationInfo authenticationInfo, JobManagerConfiguration config) throws SSHApiException {
+        this(serverInfo, authenticationInfo);
+        this.jobManagerConfiguration = config;
+    }
+
+    public GSISSHAbstractCluster(ServerInfo serverInfo, AuthenticationInfo authenticationInfo) throws SSHApiException {
+
+        this.serverInfo = serverInfo;
+
+        this.authenticationInfo = authenticationInfo;
+
+        if (authenticationInfo instanceof GSIAuthenticationInfo) {
+            System.setProperty(X509_CERT_DIR, (String) ((GSIAuthenticationInfo) authenticationInfo).getProperties().
+                    get("X509_CERT_DIR"));
+        }
+
+
+        try {
+            this.configReader = new ConfigReader();
+        } catch (IOException e) {
+            throw new SSHApiException("Unable to load system configurations.", e);
+        }
+        JSch jSch = new ExtendedJSch();
+
+        log.debug("Connecting to server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " with user name - "
+                + serverInfo.getUserName());
+
+        try {
+            session = jSch.getSession(serverInfo.getUserName(), serverInfo.getHost(), serverInfo.getPort());
+            session.setTimeout(Integer.parseInt(configReader.getConfiguration(SSH_SESSION_TIMEOUT)));
+        } catch (Exception e) {
+            throw new SSHApiException("An exception occurred while creating SSH session." +
+                    "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                    " connecting user name - "
+                    + serverInfo.getUserName(), e);
+        }
+
+        java.util.Properties config = this.configReader.getProperties();
+        session.setConfig(config);
+
+
+        //=============================================================
+        // Handling vanilla SSH pieces
+        //=============================================================
+        if (authenticationInfo instanceof SSHPasswordAuthentication) {
+            String password = ((SSHPasswordAuthentication) authenticationInfo).
+                    getPassword(serverInfo.getUserName(), serverInfo.getHost());
+
+            session.setUserInfo(new SSHAPIUIKeyboardInteractive(password));
+
+            // TODO figure out why we need to set password to session
+            session.setPassword(password);
+
+        } else if (authenticationInfo instanceof SSHPublicKeyFileAuthentication) {
+            SSHPublicKeyFileAuthentication sshPublicKeyFileAuthentication
+                    = (SSHPublicKeyFileAuthentication) authenticationInfo;
+
+            String privateKeyFile = sshPublicKeyFileAuthentication.
+                    getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
+
+            logDebug("The private key file for vanilla SSH " + privateKeyFile);
+
+            String publicKeyFile = sshPublicKeyFileAuthentication.
+                    getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
+
+            logDebug("The public key file for vanilla SSH " + publicKeyFile);
+
+            Identity identityFile;
+
+            try {
+                identityFile = GSISSHIdentityFile.newInstance(privateKeyFile, null, jSch);
+            } catch (JSchException e) {
+                throw new SSHApiException("An exception occurred while initializing keys using files. " +
+                        "(private key and public key)." +
+                        "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                        " connecting user name - "
+                        + serverInfo.getUserName() + " private key file - " + privateKeyFile + ", public key file - " +
+                        publicKeyFile, e);
+            }
+
+            // Add identity to identity repository
+            GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jSch);
+            identityRepository.add(identityFile);
+
+            // Set repository to session
+            session.setIdentityRepository(identityRepository);
+
+            // Set the user info
+            SSHKeyPasswordHandler sshKeyPasswordHandler
+                    = new SSHKeyPasswordHandler((SSHKeyAuthentication) authenticationInfo);
+
+            session.setUserInfo(sshKeyPasswordHandler);
+
+        } else if (authenticationInfo instanceof SSHPublicKeyAuthentication) {
+
+            SSHPublicKeyAuthentication sshPublicKeyAuthentication
+                    = (SSHPublicKeyAuthentication) authenticationInfo;
+
+            Identity identityFile;
+
+            try {
+                String name = serverInfo.getUserName() + "_" + serverInfo.getHost();
+                identityFile = GSISSHIdentityFile.newInstance(name,
+                        sshPublicKeyAuthentication.getPrivateKey(serverInfo.getUserName(), serverInfo.getHost()),
+                        sshPublicKeyAuthentication.getPublicKey(serverInfo.getUserName(), serverInfo.getHost()), jSch);
+            } catch (JSchException e) {
+                throw new SSHApiException("An exception occurred while initializing keys using byte arrays. " +
+                        "(private key and public key)." +
+                        "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                        " connecting user name - "
+                        + serverInfo.getUserName(), e);
+            }
+
+            // Add identity to identity repository
+            GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jSch);
+            identityRepository.add(identityFile);
+
+            // Set repository to session
+            session.setIdentityRepository(identityRepository);
+
+            // Set the user info
+            SSHKeyPasswordHandler sshKeyPasswordHandler
+                    = new SSHKeyPasswordHandler((SSHKeyAuthentication) authenticationInfo);
+
+            session.setUserInfo(sshKeyPasswordHandler);
+
+        }
+
+        // Not a good way, but we dont have any choice
+        if (session instanceof ExtendedSession) {
+            if (authenticationInfo instanceof GSIAuthenticationInfo) {
+                ((ExtendedSession) session).setAuthenticationInfo((GSIAuthenticationInfo) authenticationInfo);
+            }
+        }
+
+        try {
+            session.connect();
+        } catch (JSchException e) {
+            throw new SSHApiException("An exception occurred while connecting to server." +
+                    "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                    " connecting user name - "
+                    + serverInfo.getUserName(), e);
+        }
+        System.out.println(session.isConnected());
+    }
+
+    public JobDescriptor cancelJob(String jobID) throws SSHApiException {
+       RawCommandInfo rawCommandInfo = jobManagerConfiguration.getCancelCommand(jobID);
+
+        StandardOutReader stdOutReader = new StandardOutReader();
+        CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader);
+        String outputifAvailable = getOutputifAvailable(stdOutReader, "Error reading output of job submission");
+        // this might not be the case for all teh resources, if so Cluster implementation can override this method
+        // because here after cancelling we try to get the job description and return it back
+        JobDescriptor jobById = this.getJobDescriptorById(jobID);
+        if (CommonUtils.isJobFinished(jobById)) {
+            log.debug("Job Cancel operation was successful !");
+            return jobById;
+        } else {
+            log.debug("Job Cancel operation was not successful !");
+            return null;
+        }
+    }
+
+    public String submitBatchJobWithScript(String scriptPath, String workingDirectory) throws SSHApiException {
+        this.scpTo(workingDirectory, scriptPath);
+
+        // since this is a constant we do not ask users to fill this
+
+//        RawCommandInfo rawCommandInfo = new RawCommandInfo(this.installedPath + this.jobManagerConfiguration.getSubmitCommand() + " " +
+//                workingDirectory + File.separator + FilenameUtils.getName(scriptPath));
+
+        RawCommandInfo rawCommandInfo = jobManagerConfiguration.getSubmitCommand(workingDirectory,scriptPath);
+        StandardOutReader standardOutReader = new StandardOutReader();
+        CommandExecutor.executeCommand(rawCommandInfo, this.session, standardOutReader);
+
+        //Check whether pbs submission is successful or not, if it failed throw and exception in submitJob method
+        // with the error thrown in qsub command
+        //
+        String outputifAvailable = getOutputifAvailable(standardOutReader,"Error reading output of job submission");
+        OutputParser outputParser = jobManagerConfiguration.getParser();
+        return  outputParser.parse(outputifAvailable);
+    }
+
+    public String submitBatchJob(JobDescriptor jobDescriptor) throws SSHApiException {
+        TransformerFactory factory = TransformerFactory.newInstance();
+        URL resource = this.getClass().getClassLoader().getResource(jobManagerConfiguration.getJobDescriptionTemplateName());
+
+        if (resource == null) {
+            String error = "System configuration file '" + jobManagerConfiguration.getJobDescriptionTemplateName()
+                    + "' not found in the classpath";
+            throw new SSHApiException(error);
+        }
+
+        Source xslt = new StreamSource(new File(resource.getPath()));
+        Transformer transformer;
+        StringWriter results = new StringWriter();
+        File tempPBSFile = null;
+        try {
+            // generate the pbs script using xslt
+            transformer = factory.newTransformer(xslt);
+            Source text = new StreamSource(new ByteArrayInputStream(jobDescriptor.toXML().getBytes()));
+            transformer.transform(text, new StreamResult(results));
+            String scriptContent = results.toString().replaceAll("^[ |\t]*\n$", "");
+            if (scriptContent.startsWith("\n")) {
+                scriptContent = scriptContent.substring(1);
+            }
+//            log.debug("generated PBS:" + results.toString());
+
+            // creating a temporary file using pbs script generated above
+            int number = new SecureRandom().nextInt();
+            number = (number < 0 ? -number : number);
+
+            tempPBSFile = new File(Integer.toString(number) + jobManagerConfiguration.getScriptExtension());
+            FileUtils.writeStringToFile(tempPBSFile, scriptContent);
+
+            //reusing submitBatchJobWithScript method to submit a job
+
+            String jobID = this.submitBatchJobWithScript(tempPBSFile.getAbsolutePath(),
+                    jobDescriptor.getWorkingDirectory());
+            log.debug("Job has successfully submitted, JobID : " + jobID);
+            return jobID.replace("\n", "");
+        } catch (TransformerConfigurationException e) {
+            throw new SSHApiException("Error parsing PBS transformation", e);
+        } catch (TransformerException e) {
+            throw new SSHApiException("Error generating PBS script", e);
+        } catch (IOException e) {
+            throw new SSHApiException("An exception occurred while connecting to server." +
+                    "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+                    " connecting user name - "
+                    + serverInfo.getUserName(), e);
+        } finally {
+            if (tempPBSFile != null) {
+                tempPBSFile.delete();
+            }
+        }
+    }
+
+
+
+    public JobDescriptor getJobDescriptorById(String jobID) throws SSHApiException {
+        RawCommandInfo rawCommandInfo = jobManagerConfiguration.getMonitorCommand(jobID);
+        StandardOutReader stdOutReader = new StandardOutReader();
+        CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader);
+        String result = getOutputifAvailable(stdOutReader, "Error getting job information from the resource !");
+        JobDescriptor jobDescriptor = new JobDescriptor();
+        jobManagerConfiguration.getParser().parse(jobDescriptor,result);
+        return jobDescriptor;
+    }
+
+    public JobStatus getJobStatus(String jobID) throws SSHApiException {
+        RawCommandInfo rawCommandInfo = jobManagerConfiguration.getMonitorCommand(jobID);
+        StandardOutReader stdOutReader = new StandardOutReader();
+        CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader);
+        String result = getOutputifAvailable(stdOutReader, "Error getting job information from the resource !");
+        return jobManagerConfiguration.getParser().parse(jobID, result);
+    }
+
+    private static void logDebug(String message) {
+        if (log.isDebugEnabled()) {
+            log.debug(message);
+        }
+    }
+
+    public JobManagerConfiguration getJobManagerConfiguration() {
+        return jobManagerConfiguration;
+    }
+
+    public void setJobManagerConfiguration(JobManagerConfiguration jobManagerConfiguration) {
+        this.jobManagerConfiguration = jobManagerConfiguration;
+    }
+
+    public void scpTo(String remoteFile, String localFile) throws SSHApiException {
+        try {
+            SSHUtils.scpTo(remoteFile, localFile, session);
+        } catch (IOException e) {
+            throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file "
+                    + serverInfo.getHost() + ":rFile", e);
+        } catch (JSchException e) {
+            throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file "
+                    + serverInfo.getHost() + ":rFile", e);
+        }
+    }
+
+    public void scpFrom(String remoteFile, String localFile) throws SSHApiException {
+        try {
+            SSHUtils.scpFrom(remoteFile, localFile, session);
+        } catch (IOException e) {
+            throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file "
+                    + serverInfo.getHost() + ":rFile", e);
+        } catch (JSchException e) {
+            throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file "
+                    + serverInfo.getHost() + ":rFile", e);
+        }
+    }
+
+    public void makeDirectory(String directoryPath) throws SSHApiException {
+        try {
+            SSHUtils.makeDirectory(directoryPath, session);
+        } catch (IOException e) {
+            throw new SSHApiException("Failed during creating directory:" + directoryPath + " to remote file "
+                    + serverInfo.getHost() + ":rFile", e);
+        } catch (JSchException e) {
+            throw new SSHApiException("Failed during creating directory :" + directoryPath + " to remote file "
+                    + serverInfo.getHost() + ":rFile", e);
+        }
+    }
+
+
+    public ServerInfo getServerInfo() {
+        return serverInfo;
+    }
+
+    public AuthenticationInfo getAuthenticationInfo() {
+        return authenticationInfo;
+    }
+
+    /**
+     * This gaurantee to return a valid session
+     *
+     * @return
+     */
+    public Session getSession() {
+        return this.session;
+    }
+
+    /**
+     * This method will read standard output and if there's any it will be parsed
+     *
+     * @param jobIDReaderCommandOutput
+     * @param errorMsg
+     * @return
+     * @throws SSHApiException
+     */
+    private String getOutputifAvailable(StandardOutReader jobIDReaderCommandOutput, String errorMsg) throws SSHApiException {
+        String stdOutputString = jobIDReaderCommandOutput.getStdOutputString();
+        String stdErrorString = jobIDReaderCommandOutput.getStdErrorString();
+
+        if ((stdOutputString == null && "".equals(stdOutputString)) &&
+                ((stdErrorString != null) && !("".equals(stdErrorString)))) {
+            log.error("Standard Error output : " + stdErrorString);
+            throw new SSHApiException(errorMsg + stdErrorString);
+        }
+        return stdOutputString;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/b3581061/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java
index 7a78b89..4efeef1 100644
--- a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java
@@ -23,629 +23,20 @@ package org.apache.airavata.gsi.ssh.impl;
 import com.jcraft.jsch.*;
 import org.apache.airavata.gsi.ssh.api.*;
 import org.apache.airavata.gsi.ssh.api.authentication.*;
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
-import org.apache.airavata.gsi.ssh.config.ConfigReader;
-import org.apache.airavata.gsi.ssh.jsch.ExtendedJSch;
-import org.apache.airavata.gsi.ssh.util.CommonUtils;
-import org.apache.airavata.gsi.ssh.util.SSHAPIUIKeyboardInteractive;
-import org.apache.airavata.gsi.ssh.util.SSHKeyPasswordHandler;
-import org.apache.airavata.gsi.ssh.util.SSHUtils;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.FilenameUtils;
+import org.apache.airavata.gsi.ssh.api.job.JobManagerConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.xml.transform.*;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import java.io.*;
-import java.net.URL;
-import java.security.SecureRandom;
-import java.util.ArrayList;
 
 /**
  * This is the default implementation of a cluster.
  * this has most of the methods to be used by the end user of the
  * library.
  */
-public class PBSCluster implements Cluster {
-    static {
-        JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gsi.ssh.GSSContextX509");
-        JSch.setConfig("userauth.gssapi-with-mic", "com.jcraft.jsch.UserAuthGSSAPIWithMICGSSCredentials");
-
-    }
-
+public class PBSCluster extends GSISSHAbstractCluster {
     private static final Logger log = LoggerFactory.getLogger(PBSCluster.class);
-    public static final String X509_CERT_DIR = "X509_CERT_DIR";
-    public static final String SSH_SESSION_TIMEOUT = "ssh.session.timeout";
-    public static final String PBSTEMPLATE_XSLT = "PBSTemplate.xslt";
-
-    private Node[] Nodes;
-
-    private ServerInfo serverInfo;
-
-    private AuthenticationInfo authenticationInfo;
-
-    private Session session;
-
-    private ConfigReader configReader;
-
-    private String installedPath;
-
-    public PBSCluster(ServerInfo serverInfo, AuthenticationInfo authenticationInfo, String installedPath) throws SSHApiException {
-
-        this.serverInfo = serverInfo;
-
-        this.authenticationInfo = authenticationInfo;
-
-        if (authenticationInfo instanceof GSIAuthenticationInfo) {
-            System.setProperty(X509_CERT_DIR, (String) ((GSIAuthenticationInfo) authenticationInfo).getProperties().
-                    get("X509_CERT_DIR"));
-        }
-        if(installedPath == null) {
-            throw new SSHApiException("Installed path cannot be null !!");
-        }
-        if (installedPath.endsWith("/")) {
-            this.installedPath = installedPath;
-        } else {
-            this.installedPath = installedPath + "/";
-        }
-
-
-        try {
-            this.configReader = new ConfigReader();
-        } catch (IOException e) {
-            throw new SSHApiException("Unable to load system configurations.", e);
-        }
-        JSch jSch = new ExtendedJSch();
-
-        log.debug("Connecting to server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " with user name - "
-                + serverInfo.getUserName());
-
-        try {
-            session = jSch.getSession(serverInfo.getUserName(), serverInfo.getHost(), serverInfo.getPort());
-            session.setTimeout(Integer.parseInt(configReader.getConfiguration(SSH_SESSION_TIMEOUT)));
-        } catch (Exception e) {
-            throw new SSHApiException("An exception occurred while creating SSH session." +
-                    "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
-                    " connecting user name - "
-                    + serverInfo.getUserName(), e);
-        }
-
-        java.util.Properties config = this.configReader.getProperties();
-        session.setConfig(config);
-
-
-        //=============================================================
-        // Handling vanilla SSH pieces
-        //=============================================================
-        if (authenticationInfo instanceof SSHPasswordAuthentication) {
-            String password = ((SSHPasswordAuthentication) authenticationInfo).
-                    getPassword(serverInfo.getUserName(), serverInfo.getHost());
-
-            session.setUserInfo(new SSHAPIUIKeyboardInteractive(password));
-
-            // TODO figure out why we need to set password to session
-            session.setPassword(password);
-
-        } else if (authenticationInfo instanceof SSHPublicKeyFileAuthentication) {
-            SSHPublicKeyFileAuthentication sshPublicKeyFileAuthentication
-                    = (SSHPublicKeyFileAuthentication) authenticationInfo;
-
-            String privateKeyFile = sshPublicKeyFileAuthentication.
-                    getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
-
-            logDebug("The private key file for vanilla SSH " + privateKeyFile);
-
-            String publicKeyFile = sshPublicKeyFileAuthentication.
-                    getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
-
-            logDebug("The public key file for vanilla SSH " + publicKeyFile);
-
-            Identity identityFile;
-
-            try {
-                identityFile = GSISSHIdentityFile.newInstance(privateKeyFile, null, jSch);
-            } catch (JSchException e) {
-                throw new SSHApiException("An exception occurred while initializing keys using files. " +
-                        "(private key and public key)." +
-                        "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
-                        " connecting user name - "
-                        + serverInfo.getUserName() + " private key file - " + privateKeyFile + ", public key file - " +
-                        publicKeyFile, e);
-            }
-
-            // Add identity to identity repository
-            GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jSch);
-            identityRepository.add(identityFile);
-
-            // Set repository to session
-            session.setIdentityRepository(identityRepository);
-
-            // Set the user info
-            SSHKeyPasswordHandler sshKeyPasswordHandler
-                    = new SSHKeyPasswordHandler((SSHKeyAuthentication) authenticationInfo);
-
-            session.setUserInfo(sshKeyPasswordHandler);
-
-        } else if (authenticationInfo instanceof SSHPublicKeyAuthentication) {
-
-            SSHPublicKeyAuthentication sshPublicKeyAuthentication
-                    = (SSHPublicKeyAuthentication) authenticationInfo;
-
-            Identity identityFile;
-
-            try {
-                String name = serverInfo.getUserName() + "_" + serverInfo.getHost();
-                identityFile = GSISSHIdentityFile.newInstance(name,
-                        sshPublicKeyAuthentication.getPrivateKey(serverInfo.getUserName(), serverInfo.getHost()),
-                        sshPublicKeyAuthentication.getPublicKey(serverInfo.getUserName(), serverInfo.getHost()), jSch);
-            } catch (JSchException e) {
-                throw new SSHApiException("An exception occurred while initializing keys using byte arrays. " +
-                        "(private key and public key)." +
-                        "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
-                        " connecting user name - "
-                        + serverInfo.getUserName(), e);
-            }
-
-            // Add identity to identity repository
-            GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jSch);
-            identityRepository.add(identityFile);
-
-            // Set repository to session                                                                            j
-            session.setIdentityRepository(identityRepository);
-
-            // Set the user info
-            SSHKeyPasswordHandler sshKeyPasswordHandler
-                    = new SSHKeyPasswordHandler((SSHKeyAuthentication) authenticationInfo);
-
-            session.setUserInfo(sshKeyPasswordHandler);
-
-        }
-
-        // Not a good way, but we dont have any choice
-        if (session instanceof ExtendedSession) {
-            if (authenticationInfo instanceof GSIAuthenticationInfo) {
-                ((ExtendedSession) session).setAuthenticationInfo((GSIAuthenticationInfo) authenticationInfo);
-            }
-        }
-
-        try {
-            session.connect();
-        } catch (JSchException e) {
-            throw new SSHApiException("An exception occurred while connecting to server." +
-                    "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
-                    " connecting user name - "
-                    + serverInfo.getUserName(), e);
-        }
-        System.out.println(session.isConnected());
-    }
-
-
-    public String submitBatchJobWithPBS(String pbsFilePath, String workingDirectory) throws SSHApiException {
-
-        this.scpTo(workingDirectory, pbsFilePath);
-
-        // since this is a constant we do not ask users to fill this
-        RawCommandInfo rawCommandInfo = new RawCommandInfo(this.installedPath + "qsub " +
-                workingDirectory + File.separator + FilenameUtils.getName(pbsFilePath));
-
-        StandardOutReader jobIDReaderCommandOutput = new StandardOutReader();
-        CommandExecutor.executeCommand(rawCommandInfo, this.session, jobIDReaderCommandOutput);
-
-        //Check whether pbs submission is successful or not, if it failed throw and exception in submitJob method
-        // with the error thrown in qsub command
-        //
-        String stdOutputString = getOutputifAvailable(jobIDReaderCommandOutput, "Error submitting job to resource");
-        return stdOutputString;
-
-    }
-
-    /**
-     * This method will read standard output and if there's any it will be parsed
-     * @param jobIDReaderCommandOutput
-     * @param errorMsg
-     * @return
-     * @throws SSHApiException
-     */
-    private String getOutputifAvailable(StandardOutReader jobIDReaderCommandOutput, String errorMsg) throws SSHApiException {
-        String stdOutputString = jobIDReaderCommandOutput.getStdOutputString();
-        String stdErrorString = jobIDReaderCommandOutput.getStdErrorString();
-
-        if (stdOutputString == null && "".equals(stdOutputString) ||
-                ((stdErrorString != null) && !("".equals(stdErrorString)))) {
-            log.error("Standard Error output : " + stdErrorString);
-            throw new SSHApiException(errorMsg + stdErrorString);
-        }
-        return stdOutputString;
-    }
-
-    public String submitBatchJob(JobDescriptor jobDescriptor) throws SSHApiException {
-        TransformerFactory factory = TransformerFactory.newInstance();
-        URL resource = this.getClass().getClassLoader().getResource(PBSTEMPLATE_XSLT);
-
-        if (resource == null) {
-            String error = "System configuration file '" + PBSCluster.PBSTEMPLATE_XSLT
-                    + "' not found in the classpath";
-            throw new SSHApiException(error);
-        }
-
-        Source xslt = new StreamSource(new File(resource.getPath()));
-        Transformer transformer;
-        StringWriter results = new StringWriter();
-        File tempPBSFile = null;
-        try {
-            // generate the pbs script using xslt
-            transformer = factory.newTransformer(xslt);
-            Source text = new StreamSource(new ByteArrayInputStream(jobDescriptor.toXML().getBytes()));
-            transformer.transform(text, new StreamResult(results));
-
-            System.out.println(results.toString());
-//            log.debug("generated PBS:" + results.toString());
-
-            // creating a temporary file using pbs script generated above
-            int number = new SecureRandom().nextInt();
-            number = (number < 0 ? -number : number);
-
-            tempPBSFile = new File(Integer.toString(number) + ".pbs");
-            FileUtils.writeStringToFile(tempPBSFile, results.toString());
-
-            //reusing submitBatchJobWithPBS method to submit a job
-
-            String jobID = this.submitBatchJobWithPBS(tempPBSFile.getAbsolutePath(),
-                    jobDescriptor.getWorkingDirectory());
-            log.debug("Job has successfully submitted, JobID : " + jobID);
-            return jobID.replace("\n", "");
-        } catch (TransformerConfigurationException e) {
-            throw new SSHApiException("Error parsing PBS transformation", e);
-        } catch (TransformerException e) {
-            throw new SSHApiException("Error generating PBS script", e);
-        } catch (IOException e) {
-            throw new SSHApiException("An exception occurred while connecting to server." +
-                    "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
-                    " connecting user name - "
-                    + serverInfo.getUserName(), e);
-        } finally {
-            if (tempPBSFile != null) {
-                tempPBSFile.delete();
-            }
-        }
-    }
-
-
-    public Cluster loadCluster() throws SSHApiException {
-        RawCommandInfo rawCommandInfo = new RawCommandInfo(this.installedPath + "qnodes");
-
-        StandardOutReader stdOutReader = new StandardOutReader();
-        CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader);
-
-        String result = getOutputifAvailable(stdOutReader, "Error getting cluster information !");
-        String[] Nodes = result.split("\n");
-        String[] line;
-        String header, value;
-        Node Node;
-        Core[] Cores = null;
-        ArrayList<Node> Machines = new ArrayList<Node>();
-        int i = 0;
-        while (i < Nodes.length) {
-            Node = new Node();
-            Node.setName(Nodes[i]);
-            i++;
-
-            while (i < Nodes.length) {
-                if (!Nodes[i].startsWith(" ")) {
-                    i++;
-                    break;
-                }
-
-                line = Nodes[i].split("=");
-                header = line[0].trim();
-                value = line[1].trim();
-
-                if ("state".equals(header))
-                    Node.setState(value);
-                else if ("np".equals(header)) {
-                    Node.setNp(value);
-                    int np = Integer.parseInt(Node.getNp());
-                    Cores = new Core[np];
-                    for (int n = 0; n < np; n++) {
-                        Cores[n] = new Core("" + n);
-                    }
-                } else if ("ntype".equals(header))
-                    Node.setNtype(value);
-                else if ("jobs".equals(header)) {
-                    String[] jobs = value.split(", ");
-                    JobDescriptor jo;
-                    //Job[] Jobs = new Job[jobs.length];
-                    for (String job : jobs) {
-                        String[] c = job.split("/");
-                        String Jid = c[1];
-                        jo = this.getJobDescriptorById(Jid);
-                        int core = Integer.parseInt(c[0]);
-                        assert Cores != null;
-                        Cores[core].setJob(jo);
-
-                    }
-
-
-                }
-                i++;
-            }
-            Node.setCores(Cores);
-            Machines.add(Node);
-        }
-        this.setNodes(Machines.toArray(new Node[Machines.size()]));
-        return this;
-    }
-
-
-    public JobDescriptor getJobDescriptorById(String jobID) throws SSHApiException {
-        RawCommandInfo rawCommandInfo = new RawCommandInfo(this.installedPath + "qstat -f " + jobID);
-
-        StandardOutReader stdOutReader = new StandardOutReader();
-        CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader);
-
-        String result = getOutputifAvailable(stdOutReader, "Error getting job information from the resource !");;
-        String[] info = result.split("\n");
-        JobDescriptor jobDescriptor = new JobDescriptor();
-        String[] line;
-        for (int i = 0; i < info.length; i++) {
-            if (info[i].contains("=")) {
-                line = info[i].split("=", 2);
-            } else {
-                line = info[i].split(":", 2);
-            }
-            if (line.length >= 2) {
-                String header = line[0].trim();
-                log.debug("Header = " + header);
-                String value = line[1].trim();
-                log.debug("value = " + value);
-
-                if (header.equals("Variable_List")) {
-                    while (info[i + 1].startsWith("\t")) {
-                        value += info[i + 1];
-                        i++;
-                    }
-                    value = value.replaceAll("\t", "");
-                    jobDescriptor.setVariableList(value);
-                } else if ("Job Id".equals(header)) {
-                    jobDescriptor.setJobID(value);
-                } else if ("Job_Name".equals(header)) {
-                    jobDescriptor.setJobName(value);
-                } else if ("Account_Name".equals(header)) {
-                    jobDescriptor.setAcountString(value);
-                } else if ("job_state".equals(header)) {
-                    jobDescriptor.setStatus(value);
-                } else if ("Job_Owner".equals(header)) {
-                    jobDescriptor.setOwner(value);
-                } else if ("resources_used.cput".equals(header)) {
-                    jobDescriptor.setUsedCPUTime(value);
-                } else if ("resources_used.mem".equals(header)) {
-                    jobDescriptor.setUsedMemory(value);
-                } else if ("resources_used.walltime".equals(header)) {
-                    jobDescriptor.setEllapsedTime(value);
-                } else if ("job_state".equals(header)) {
-                    jobDescriptor.setStatus(value);
-                } else if ("queue".equals(header))
-                    jobDescriptor.setQueueName(value);
-                else if ("ctime".equals(header)) {
-                    jobDescriptor.setCTime(value);
-                } else if ("qtime".equals(header)) {
-                    jobDescriptor.setQTime(value);
-                } else if ("mtime".equals(header)) {
-                    jobDescriptor.setMTime(value);
-                } else if ("start_time".equals(header)) {
-                    jobDescriptor.setSTime(value);
-                } else if ("comp_time".equals(header)) {
-                    jobDescriptor.setCompTime(value);
-                } else if ("exec_host".equals(header)) {
-                    jobDescriptor.setExecuteNode(value);
-                } else if ("Output_Path".equals(header)) {
-                    if (info[i + 1].contains("=") || info[i + 1].contains(":"))
-                        jobDescriptor.setStandardOutFile(value);
-                    else {
-                        jobDescriptor.setStandardOutFile(value + info[i + 1].trim());
-                        i++;
-                    }
-                } else if ("Error_Path".equals(header)) {
-                    if (info[i + 1].contains("=") || info[i + 1].contains(":"))
-                        jobDescriptor.setStandardErrorFile(value);
-                    else {
-                        String st = info[i + 1].trim();
-                        jobDescriptor.setStandardErrorFile(value + st);
-                        i++;
-                    }
-
-                } else if ("submit_args".equals(header)) {
-                    while (i + 1 < info.length) {
-                        if (info[i + 1].startsWith("\t")) {
-                            value += info[i + 1];
-                            i++;
-                        } else
-                            break;
-                    }
-                    value = value.replaceAll("\t", "");
-                    jobDescriptor.setSubmitArgs(value);
-                }
-            }
-        }
-        return jobDescriptor;
-    }
-
-    public void scpTo(String remoteFile, String localFile) throws SSHApiException {
-        try {
-            SSHUtils.scpTo(remoteFile, localFile, session);
-        } catch (IOException e) {
-            throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file "
-                    + serverInfo.getHost() + ":rFile", e);
-        } catch (JSchException e) {
-            throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file "
-                    + serverInfo.getHost() + ":rFile", e);
-        }
-    }
-
-    public void scpFrom(String remoteFile, String localFile) throws SSHApiException {
-        try {
-            SSHUtils.scpFrom(remoteFile, localFile, session);
-        } catch (IOException e) {
-            throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file "
-                    + serverInfo.getHost() + ":rFile", e);
-        } catch (JSchException e) {
-            throw new SSHApiException("Failed during scping local file:" + localFile + " to remote file "
-                    + serverInfo.getHost() + ":rFile", e);
-        }
-    }
-
-    public void makeDirectory(String directoryPath) throws SSHApiException {
-        try {
-            SSHUtils.makeDirectory(directoryPath, session);
-        } catch (IOException e) {
-            throw new SSHApiException("Failed during creating directory:" + directoryPath + " to remote file "
-                    + serverInfo.getHost() + ":rFile", e);
-        } catch (JSchException e) {
-            throw new SSHApiException("Failed during creating directory :" + directoryPath + " to remote file "
-                    + serverInfo.getHost() + ":rFile", e);
-        }
-    }
-
-//
-//    public String submitAsyncJob(Job jobDescriptor, JobSubmissionListener listener) throws SSHApiException {
-////        final Cluster cluster = this;
-//        String jobID = this.submitBatchJob(jobDescriptor);
-////        final JobSubmissionListener jobSubmissionListener = listener;
-//        try {
-//            // Wait 5 seconds to start the first poll, this is hard coded, user doesn't have
-//            // to configure this.
-//            Thread.sleep(5000);
-//        } catch (InterruptedException e) {
-//            log.error("Error during job status monitoring");
-//            throw new SSHApiException("Error during job status monitoring", e);
-//        }
-//        // Get the job status first
-//        try {
-////
-////            Thread t = new Thread() {
-////                @Override
-////                public void run() {
-////                    try {
-//            Job jobById = this.getJobDescriptorById(jobID);
-//            while (true) {
-//                while (!jobById.getStatus().equals(JobStatus.C.toString())) {
-//                    if (!jobById.getStatus().equals(listener.getJobStatus().toString())) {
-//                        listener.setJobStatus(JobStatus.fromString(jobById.getStatus()));
-//                        listener.statusChanged(jobById);
-//                    }
-//                    Thread.sleep(Long.parseLong(configReader.getConfiguration(POLLING_FREQUENCEY)));
-//
-//                    jobById = this.getJobDescriptorById(jobID);
-//                }
-//                //Set the job status to Complete
-//                listener.setJobStatus(JobStatus.C);
-//                listener.statusChanged(jobById);
-//                break;
-//            }
-////                    } catch (InterruptedException e) {
-////                        log.error("Error listening to the submitted job", e);
-////                    } catch (SSHApiException e) {
-////                        log.error("Error listening to the submitted job", e);
-////                    }
-////                }
-////            };
-//            //  This thread runs until the program termination, so that use can provide
-//            // any action in onChange method of the listener, without worrying for waiting in the caller thread.
-//            //t.setDaemon(true);
-////            t.start();
-//        } catch (Exception e) {
-//            log.error("Error during job status monitoring");
-//            throw new SSHApiException("Error during job status monitoring", e);
-//        }
-//        return jobID;  //To change body of implemented methods use File | Settings | File Templates.
-//    }
-
-    public JobStatus getJobStatus(String jobID) throws SSHApiException {
-        RawCommandInfo rawCommandInfo = new RawCommandInfo(this.installedPath + "qstat -f " + jobID);
-
-        StandardOutReader stdOutReader = new StandardOutReader();
-        CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader);
-
-
-        String result = getOutputifAvailable(stdOutReader,"Error getting job status with job ID: " + jobID);
-        String[] info = result.split("\n");
-        String[] line = null;
-        for (String anInfo : info) {
-            if (anInfo.contains("=")) {
-                line = anInfo.split("=", 2);
-                if (line.length != 0) {
-                    if (line[0].contains("job_state")) {
-                        return JobStatus.valueOf(line[1].replaceAll(" ", ""));
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    public JobDescriptor cancelJob(String jobID) throws SSHApiException {
-        RawCommandInfo rawCommandInfo = new RawCommandInfo(this.installedPath + "qdel " + jobID);
-
-        StandardOutReader stdOutReader = new StandardOutReader();
-        CommandExecutor.executeCommand(rawCommandInfo, this.getSession(), stdOutReader);
-
-        getOutputifAvailable(stdOutReader, "Error cancelling job with Job ID : " + jobID);
-
-        JobDescriptor jobById = this.getJobDescriptorById(jobID);
-        if (CommonUtils.isJobFinished(jobById)) {
-            log.debug("Job Cancel operation was successful !");
-            return jobById;
-        } else {
-            log.debug("Job Cancel operation was not successful !");
-            return null;
-        }
-    }
-
-    public void setServerInfo(ServerInfo serverInfo) {
-        this.serverInfo = serverInfo;
-    }
-
-    public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
-        this.authenticationInfo = authenticationInfo;
-    }
-
-    public void setSession(Session session) {
-        this.session = session;
-    }
-
-    /**
-     * @return cluster Nodes as array of machines
-     */
-    public Node[] getNodes() {
-        return Nodes;
-    }
-
-    public void setNodes(Node[] Nodes) {
-        this.Nodes = Nodes;
-    }
-
-    public ServerInfo getServerInfo() {
-        return serverInfo;
-    }
-
-    public AuthenticationInfo getAuthenticationInfo() {
-        return authenticationInfo;
-    }
-
-    /**
-     * This gaurantee to return a valid session
-     *
-     * @return
-     */
-    public Session getSession() {
-        return this.session;
-    }
 
-    private static void logDebug(String message) {
-        if (log.isDebugEnabled()) {
-            log.debug(message);
-        }
+    public PBSCluster(ServerInfo serverInfo, AuthenticationInfo authenticationInfo, JobManagerConfiguration config) throws SSHApiException {
+        super(serverInfo, authenticationInfo,config);
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/b3581061/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/CommonUtils.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/CommonUtils.java b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/CommonUtils.java
index c6a17bc..351c460 100644
--- a/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/CommonUtils.java
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/CommonUtils.java
@@ -20,13 +20,15 @@
 */
 package org.apache.airavata.gsi.ssh.util;
 
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
+import org.apache.airavata.gsi.ssh.api.job.*;
 import org.apache.airavata.gsi.ssh.impl.JobStatus;
+import org.apache.airavata.gsi.ssh.impl.RawCommandInfo;
 
 public class CommonUtils {
     /**
      * This returns true if the give job is finished
      * otherwise false
+     *
      * @param job
      * @return
      */
@@ -40,6 +42,7 @@ public class CommonUtils {
 
     /**
      * This will read
+     *
      * @param maxWalltime
      * @return
      */
@@ -52,4 +55,11 @@ public class CommonUtils {
             return hours + ":" + minutes + ":00";
         }
     }
+    public static JobManagerConfiguration getPBSJobManager(String installedPath) {
+        return new PBSJobConfiguration("PBSTemplate.xslt",".pbs", installedPath, new PBSOutputParser());
+    }
+
+    public static JobManagerConfiguration getSLURMJobManager(String installedPath) {
+        return new SlurmJobConfiguration("SLURMTemplate.xslt", ".slurm", installedPath, new SlurmOutputParser());
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/b3581061/tools/gsissh/src/main/resources/SLURMTemplate.xslt
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/resources/SLURMTemplate.xslt b/tools/gsissh/src/main/resources/SLURMTemplate.xslt
new file mode 100644
index 0000000..169dbbf
--- /dev/null
+++ b/tools/gsissh/src/main/resources/SLURMTemplate.xslt
@@ -0,0 +1,69 @@
+<!--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">
+<xsl:choose>
+<xsl:when test="ns:shellName">
+#!<xsl:value-of select="ns:shellName"/>
+    </xsl:when>
+    </xsl:choose>
+<xsl:choose>
+    <xsl:when test="ns:queueName">
+#SBATCH -p <xsl:value-of select="ns:queueName"/>
+    </xsl:when>
+    </xsl:choose>
+<xsl:choose>
+    <xsl:when test="ns:nodes">
+#SBATCH -n <xsl:value-of select="ns:nodes"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:mailAddress">
+#SBATCH -mail-user=<xsl:value-of select="ns:mailAddress"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:mailType">
+#SBATCH -mail-type=<xsl:value-of select="ns:mailType"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+<xsl:when test="ns:acountString">
+#SBATCH -A <xsl:value-of select="ns:acountString"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:maxWallTime">
+#SBATCH -t <xsl:value-of select="ns:maxWallTime"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:jobName">
+#SBATCH -J <xsl:value-of select="ns:jobName"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:standardOutFile">
+#SBATCH -o <xsl:value-of select="ns:standardOutFile"/>
+    </xsl:when>
+    </xsl:choose>
+    <xsl:choose>
+    <xsl:when test="ns:standardOutFile">
+#SBATCH -e <xsl:value-of select="ns:standardErrorFile"/>
+    </xsl:when>
+    </xsl:choose>
+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:template>
+
+</xsl:stylesheet>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/b3581061/tools/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd b/tools/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd
index db65e4f..0e84612 100644
--- a/tools/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd
+++ b/tools/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd
@@ -15,11 +15,15 @@
 	<complexType name="pbsParams">
 		<sequence>
             <element name="jobID" type="xsd:string" minOccurs="0" maxOccurs="1"/>
+            <element name="userName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
 			<element name="shellName" type="xsd:string" minOccurs="0" maxOccurs="1" default="/bin/bash"/>
             <element name="queueName" type="xsd:string" minOccurs="0" maxOccurs="1" default="normal"/>
             <element name="jobName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
             <element name="allEnvExport" type="xsd:boolean" minOccurs="0 " maxOccurs="1" default="true"/>
 			<element name="mailOptions" type="xsd:string" minOccurs="0" maxOccurs="1" />
+            <element name="mailAddress" type="xsd:string" minOccurs="0" maxOccurs="1" />
+            <element name="partition" type="xsd:string" minOccurs="0" maxOccurs="1" />
+            <element name="mailType" type="xsd:string" minOccurs="0" maxOccurs="1" />
 			<element name="acountString" type="xsd:string" minOccurs="0" maxOccurs="1" />
 			<element name="maxWallTime" type="xsd:string" minOccurs="0" maxOccurs="1" default="1:00:00"/>
             <element name="standardOutFile" type="xsd:string" minOccurs="0" maxOccurs="1" />
@@ -28,6 +32,7 @@
             <element name="inputDirectory" type="xsd:string" minOccurs="0" maxOccurs="1" />
             <element name="nodes" type="xsd:int" minOccurs="0" maxOccurs="1" default="1"/>
             <element name="processesPerNode" type="xsd:int" minOccurs="0" maxOccurs="1" default="1" />
+            <element name="nodeList" type="xsd:string" minOccurs="0" maxOccurs="1" default="1" />
             <element name="workingDirectory" type="xsd:string" minOccurs="0" maxOccurs="1" />
             <element name="executablePath" type="xsd:string" minOccurs="0" maxOccurs="1" />
             <element name="inputs" type="gsissh:inputList" minOccurs="1" maxOccurs="1"/>

http://git-wip-us.apache.org/repos/asf/airavata/blob/b3581061/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
index c2bc055..c339d9d 100644
--- a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
+++ b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
@@ -45,17 +45,19 @@ public class DefaultSSHApiTest {
     private String certificateLocation;
     private String pbsFilePath;
     private String workingDirectory;
+    private String slurmWorkingDirectory;
     private String jobID;
 
     @BeforeTest
     public void setUp() throws Exception {
-//        System.setProperty("myproxy.user", "ogce");
-//        System.setProperty("myproxy.password", "");
-//        System.setProperty("basedir", "/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
-//        System.setProperty("gsi.working.directory","/home/ogce");
+        System.setProperty("myproxy.user", "ogce");
+        System.setProperty("myproxy.password", "0Gce3098");
+        System.setProperty("basedir", "/Users/lahirugunathilake/Downloads");
+        System.setProperty("gsi.working.directory", "/home/ogce");
         myProxyUserName = System.getProperty("myproxy.user");
         myProxyPassword = System.getProperty("myproxy.password");
         workingDirectory = System.getProperty("gsi.working.directory");
+        slurmWorkingDirectory = "/home1/01437/ogce";
         String pomDirectory = System.getProperty("basedir");
 
         File pomFileDirectory = new File(pomDirectory);
@@ -96,10 +98,8 @@ public class DefaultSSHApiTest {
     }
 
 
-
-
     @Test
-    public void testSubmitAsyncJob() throws Exception {
+    public void testPBSAsync() throws Exception {
         // Create authentication
         GSIAuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
@@ -109,7 +109,7 @@ public class DefaultSSHApiTest {
         ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
 
 
-        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, "/opt/torque/bin/");
+        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
 
 
         // Execute command
@@ -162,6 +162,72 @@ public class DefaultSSHApiTest {
         System.out.println(jobById.getVariableList());
     }
 
+    @Test
+    public void testSLURMAsync() throws Exception {
+        // Create authentication
+        GSIAuthenticationInfo authenticationInfo
+                = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+                7512, 17280000, certificateLocation);
+
+        // Server info
+        ServerInfo serverInfo = new ServerInfo("ogce", "stampede.tacc.xsede.org");
+        serverInfo.setPort(2222);
+
+        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getSLURMJobManager("/usr/bin/"));
+
+
+        // Execute command
+        System.out.println("Target SLURM file path: " + slurmWorkingDirectory);
+        // constructing the job object
+        JobDescriptor jobDescriptor = new JobDescriptor();
+        jobDescriptor.setWorkingDirectory(slurmWorkingDirectory);
+        jobDescriptor.setShellName("/bin/sh");
+        jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
+        jobDescriptor.setExecutablePath("/bin/echo");
+        jobDescriptor.setAllEnvExport(true);
+        jobDescriptor.setMailOptions("n");
+        jobDescriptor.setStandardOutFile("" + File.separator + "application.out");
+        jobDescriptor.setStandardErrorFile("/home1/01437/ogce" + File.separator + "application.err");
+        jobDescriptor.setNodes(1);
+        jobDescriptor.setProcessesPerNode(1);
+        jobDescriptor.setQueueName("normal");
+        jobDescriptor.setMaxWallTime("60");
+        jobDescriptor.setAcountString("TG-STA110014S");
+        jobDescriptor.setJobSubmitter("sbatch");
+        List<String> inputs = new ArrayList<String>();
+        inputs.add("Hello World");
+        jobDescriptor.setInputValues(inputs);
+        //finished construction of job object
+        System.out.println(jobDescriptor.toXML());
+        jobID = pbsCluster.submitBatchJob(jobDescriptor);
+        System.out.println("JobID returned : " + jobID);
+
+//        Cluster cluster = sshApi.getCluster(serverInfo, authenticationInfo);
+//    Thread.sleep(1000);
+
+        JobDescriptor jobById = pbsCluster.getJobDescriptorById(jobID);
+
+        //printing job data got from previous call
+        AssertJUnit.assertEquals(jobById.getJobId(), jobID);
+        System.out.println(jobById.getAcountString());
+        System.out.println(jobById.getAllEnvExport());
+        System.out.println(jobById.getCompTime());
+        System.out.println(jobById.getExecutablePath());
+        System.out.println(jobById.getEllapsedTime());
+        System.out.println(jobById.getQueueName());
+        System.out.println(jobById.getExecuteNode());
+        System.out.println(jobById.getJobName());
+        System.out.println(jobById.getCTime());
+        System.out.println(jobById.getSTime());
+        System.out.println(jobById.getMTime());
+        System.out.println(jobById.getCompTime());
+        System.out.println(jobById.getOwner());
+        System.out.println(jobById.getQTime());
+        System.out.println(jobById.getUsedCPUTime());
+        System.out.println(jobById.getUsedMemory());
+        System.out.println(jobById.getVariableList());
+    }
+
 
     @Test
     public void testGetCluster() throws Exception {
@@ -192,7 +258,7 @@ public class DefaultSSHApiTest {
         // Server info
         ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
 
-        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, "/opt/torque/bin/");
+        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
 
         // Execute command
         System.out.println("Target PBS file path: " + workingDirectory);
@@ -235,7 +301,7 @@ public class DefaultSSHApiTest {
         ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
 
 
-        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, "/opt/torque/bin/");
+        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
 
 
         // Execute command
@@ -325,7 +391,7 @@ public class DefaultSSHApiTest {
         ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
 
 
-        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, "/opt/torque/bin/");
+        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
 
 
         // Execute command

http://git-wip-us.apache.org/repos/asf/airavata/blob/b3581061/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
index 3e46aa4..0f4a205 100644
--- a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
+++ b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
@@ -27,6 +27,7 @@ import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
 import org.apache.airavata.gsi.ssh.config.ConfigReader;
 import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPasswordAuthenticationInfo;
 import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPublicKeyFileAuthentication;
+import org.apache.airavata.gsi.ssh.util.CommonUtils;
 import org.testng.AssertJUnit;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -114,7 +115,7 @@ public class VanilaSSHTest {
         }
         // Server info
         ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
-        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, "/opt/torque/torque-4.2.3.1/bin/");
+        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/torque-4.2.3.1/bin/"));
 
         String date = new Date().toString();
         date = date.replaceAll(" ", "_");
@@ -197,7 +198,7 @@ public class VanilaSSHTest {
         }
         // Server info
         ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
-        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, "/opt/torque/torque-4.2.3.1/bin/");
+        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/torque-4.2.3.1/bin/"));
 
         String date = new Date().toString();
         date = date.replaceAll(" ", "_");

http://git-wip-us.apache.org/repos/asf/airavata/blob/b3581061/tools/gsissh/src/test/resources/gsissh.properties
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/test/resources/gsissh.properties b/tools/gsissh/src/test/resources/gsissh.properties
new file mode 100644
index 0000000..3fdf76d
--- /dev/null
+++ b/tools/gsissh/src/test/resources/gsissh.properties
@@ -0,0 +1,26 @@
+#
+#
+# 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.
+#
+
+###########################################################################
+# Specifies system level configurations as a key/value pairs.
+###########################################################################
+
+StrictHostKeyChecking=no
+ssh.session.timeout=360000


Mime
View raw message