You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2015/06/03 20:14:24 UTC
[07/39] airavata git commit: Refactored gfac sub modules,
merged gfac-ssh, gfac-gsissh, gfac-local,
gfac-monitor and gsissh modules and create gface-impl,
removed implementation from gfac-core to gfac-impl
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACPassiveJobSubmitter.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACPassiveJobSubmitter.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACPassiveJobSubmitter.java
index 36282a0..21df198 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACPassiveJobSubmitter.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACPassiveJobSubmitter.java
@@ -25,7 +25,7 @@ import org.apache.airavata.common.utils.AiravataUtils;
import org.apache.airavata.common.utils.ServerSettings;
import org.apache.airavata.credential.store.store.CredentialReader;
import org.apache.airavata.gfac.client.GFACInstance;
-import org.apache.airavata.gfac.core.utils.GFacUtils;
+import org.apache.airavata.gfac.core.GFacUtils;
import org.apache.airavata.messaging.core.MessageContext;
import org.apache.airavata.messaging.core.Publisher;
import org.apache.airavata.messaging.core.PublisherFactory;
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java b/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
index 4ef9dbc..389913b 100644
--- a/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
+++ b/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
@@ -36,7 +36,7 @@ import org.apache.airavata.common.utils.Constants;
import org.apache.airavata.common.utils.ServerSettings;
import org.apache.airavata.credential.store.store.CredentialReader;
import org.apache.airavata.gfac.core.scheduler.HostScheduler;
-import org.apache.airavata.gfac.core.utils.GFacUtils;
+import org.apache.airavata.gfac.core.GFacUtils;
import org.apache.airavata.messaging.core.MessageContext;
import org.apache.airavata.messaging.core.MessageHandler;
import org.apache.airavata.messaging.core.MessagingConstants;
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2234b67..23f5f16 100644
--- a/pom.xml
+++ b/pom.xml
@@ -556,7 +556,6 @@
<module>modules/security</module>
<module>modules/credential-store</module>
<module>modules/orchestrator</module>
- <module>tools</module>
<module>modules/server</module>
<module>modules/test-suite</module>
<module>modules/distribution</module>
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh-cli-tools/README.txt
----------------------------------------------------------------------
diff --git a/tools/gsissh-cli-tools/README.txt b/tools/gsissh-cli-tools/README.txt
index bc352dd..11d2674 100644
--- a/tools/gsissh-cli-tools/README.txt
+++ b/tools/gsissh-cli-tools/README.txt
@@ -6,4 +6,4 @@ To run the SSHApiClientWithMyProxyAuth tool, first add all the jars in target/li
export CP=`echo ./target/lib/*.jar | tr ' ' ':'`
Then use the following command line:
-java -classpath ./target/gsissh-cli-tools-0.14-SNAPSHOT.jar:$CP -Dmyproxy.server=myproxy.teragrid.org -Dmyproxy.username=<your.username> -Dmyproxy.password=<your.password> -Dmyproxy.cert.location=<path-to>/airavata/tools/gsissh-cli-tools/target/classes/certificates/ -Dremote.host=trestles.sdsc.xsede.org -Dremote.host.port=22 -Dremote.cmd=/bin/ls org.apache.airavata.gsi.ssh.cli.SSHApiClientWithMyProxyAuth
+java -classpath ./target/gsissh-cli-tools-0.14-SNAPSHOT.jar:$CP -Dmyproxy.server=myproxy.teragrid.org -Dmyproxy.username=<your.username> -Dmyproxy.password=<your.password> -Dmyproxy.cert.location=<path-to>/airavata/tools/gsissh-cli-tools/target/classes/certificates/ -Dremote.host=trestles.sdsc.xsede.org -Dremote.host.port=22 -Dremote.cmd=/bin/ls org.apache.airavata.gfac.ssh.cli.SSHApiClientWithMyProxyAuth
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh-cli-tools/src/main/java/org/apache/airavata/gsi/ssh/cli/SSHApiClientWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/tools/gsissh-cli-tools/src/main/java/org/apache/airavata/gsi/ssh/cli/SSHApiClientWithMyProxyAuth.java b/tools/gsissh-cli-tools/src/main/java/org/apache/airavata/gsi/ssh/cli/SSHApiClientWithMyProxyAuth.java
index 9179f08..b22dc61 100644
--- a/tools/gsissh-cli-tools/src/main/java/org/apache/airavata/gsi/ssh/cli/SSHApiClientWithMyProxyAuth.java
+++ b/tools/gsissh-cli-tools/src/main/java/org/apache/airavata/gsi/ssh/cli/SSHApiClientWithMyProxyAuth.java
@@ -19,25 +19,20 @@
*
*/
-package org.apache.airavata.gsi.ssh.cli;
+package org.apache.airavata.gfac.ssh.cli;
-import org.apache.airavata.gsi.ssh.api.*;
-import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
-import org.apache.airavata.gsi.ssh.config.ConfigReader;
-import org.apache.airavata.gsi.ssh.impl.PBSCluster;
-import org.apache.airavata.gsi.ssh.impl.RawCommandInfo;
-import org.apache.airavata.gsi.ssh.impl.SystemCommandOutput;
-import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.gfac.ssh.api.*;
+import org.apache.airavata.gfac.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gfac.ssh.api.job.JobDescriptor;
+import org.apache.airavata.gfac.ssh.config.ConfigReader;
+import org.apache.airavata.gfac.ssh.impl.PBSCluster;
+import org.apache.airavata.gfac.ssh.impl.RawCommandInfo;
+import org.apache.airavata.gfac.ssh.impl.SystemCommandOutput;
+import org.apache.airavata.gfac.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.apache.airavata.gfac.ssh.util.CommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
public class SSHApiClientWithMyProxyAuth {
public static void main(String[]ars){
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/SSHDemo.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/SSHDemo.java b/tools/gsissh/src/main/java/SSHDemo.java
index c5e410c..ea73e3c 100644
--- a/tools/gsissh/src/main/java/SSHDemo.java
+++ b/tools/gsissh/src/main/java/SSHDemo.java
@@ -39,7 +39,7 @@
*/
import com.jcraft.jsch.*;
-import org.apache.airavata.gsi.ssh.jsch.ExtendedJSch;
+import org.apache.airavata.gfac.ssh.jsch.ExtendedJSch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,7 +54,7 @@ public class SSHDemo {
private static final Logger logger = LoggerFactory.getLogger(SSHDemo.class);
static {
- JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gsi.ssh.GSSContextX509");
+ JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gfac.ssh.GSSContextX509");
JSch.setConfig("userauth.gssapi-with-mic", "com.jcraft.jsch.UserAuthGSSAPIWithMICGSSCredentials");
System.setProperty("X509_CERT_DIR",
"/Users/smarru/deploy/certificates");
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java b/tools/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java
index f3ead64..5b7f7d7 100644
--- a/tools/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java
+++ b/tools/gsissh/src/main/java/com/jcraft/jsch/ExtendedSession.java
@@ -21,7 +21,7 @@
package com.jcraft.jsch;
-import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gfac.ssh.api.authentication.GSIAuthenticationInfo;
public class ExtendedSession extends Session {
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java b/tools/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java
index 24028b6..d9fb822 100644
--- a/tools/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java
+++ b/tools/gsissh/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMICGSSCredentials.java
@@ -25,8 +25,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.apache.airavata.gsi.ssh.GSSContextX509;
-import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gfac.ssh.GSSContextX509;
+import org.apache.airavata.gfac.ssh.api.authentication.GSIAuthenticationInfo;
import org.globus.gsi.gssapi.GSSConstants;
import org.ietf.jgss.GSSException;
import org.ietf.jgss.Oid;
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java
new file mode 100644
index 0000000..1c07a39
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java
@@ -0,0 +1,210 @@
+/*
+ *
+ * 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.gfac.ssh;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.globus.common.CoGProperties;
+import org.globus.gsi.gssapi.auth.HostAuthorization;
+import org.gridforum.jgss.ExtendedGSSCredential;
+import org.gridforum.jgss.ExtendedGSSManager;
+import org.ietf.jgss.GSSContext;
+import org.ietf.jgss.GSSCredential;
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.GSSName;
+import org.ietf.jgss.MessageProp;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.jcraft.jsch.JSchException;
+
+/**
+ * This class is based on GSSContextKrb5; it substitutes the globus
+ * ExtendedGSSManager and uses the SecurityUtils method to get the credential if
+ * one is not passed in from memory.
+ *
+ */
+public class GSSContextX509 implements com.jcraft.jsch.GSSContext {
+
+ private GSSContext context = null;
+ private GSSCredential credential;
+ private static final Logger logger = LoggerFactory.getLogger(GSSContextX509.class);
+
+ public void create(String user, String host) throws JSchException {
+ try {
+// ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance();
+
+ if (credential == null) {
+ try {
+ credential = getCredential();
+ } catch (SecurityException t) {
+ System.out.printf("Could not get proxy: %s: %s\n", t.getClass().getSimpleName(), t.getMessage());
+ throw new JSchException(t.toString());
+ }
+ }
+
+ String cname = host;
+
+ try {
+ cname = InetAddress.getByName(cname).getCanonicalHostName();
+ } catch (UnknownHostException e) {
+ }
+
+ GSSName name = HostAuthorization.getInstance().getExpectedName(credential, cname);
+
+// context = manager.createContext(name, null, credential, GSSContext.DEFAULT_LIFETIME);
+//
+// // RFC4462 3.4. GSS-API Session
+// //
+// // When calling GSS_Init_sec_context(), the client MUST set
+// // integ_req_flag to "true" to request that per-message integrity
+// // protection be supported for this context. In addition,
+// // deleg_req_flag MAY be set to "true" to request access delegation,
+// // if
+// // requested by the user.
+// //
+// // Since the user authentication process by its nature authenticates
+// // only the client, the setting of mutual_req_flag is not needed for
+// // this process. This flag SHOULD be set to "false".
+//
+// // TODO: OpenSSH's sshd does accept 'false' for mutual_req_flag
+// // context.requestMutualAuth(false);
+// context.requestMutualAuth(true);
+// context.requestConf(true);
+// context.requestInteg(true); // for MIC
+// context.requestCredDeleg(true);
+// context.requestAnonymity(false);
+
+// context = new BCGSSContextImpl(name, (GlobusGSSCredentialImpl) credential);
+// context.requestLifetime(GSSCredential.DEFAULT_LIFETIME);
+// context.requestCredDeleg(true);
+// context.requestMutualAuth(true);
+// context.requestReplayDet(true);
+// context.requestSequenceDet(true);
+// context.requestConf(false);
+// context.requestInteg(true);
+// ((ExtendedGSSContext)context).setOption(GSSConstants.DELEGATION_TYPE, GSIConstants.DELEGATION_TYPE_FULL);
+
+ return;
+ } catch (GSSException ex) {
+ throw new JSchException(ex.toString());
+ }
+ }
+
+ private static GSSCredential getProxy() {
+ return getProxy(null, GSSCredential.DEFAULT_LIFETIME);
+ }
+
+ /**
+ * @param x509_USER_PROXY
+ * path to the proxy.
+ * @param credentialLifetime
+ * in seconds.
+ * @return valid credential.
+ * if proxy task throws exception (or if proxy cannot be found).
+ */
+ private static GSSCredential getProxy(String x509_USER_PROXY, int credentialLifetime) throws SecurityException {
+ if (x509_USER_PROXY == null)
+ x509_USER_PROXY = System.getProperty("x509.user.proxy");
+
+// if (x509_USER_PROXY == null) {
+// SystemUtils.envToProperties();
+// x509_USER_PROXY = System.getProperty("x509.user.proxy");
+// }
+
+ if (x509_USER_PROXY == null || "".equals(x509_USER_PROXY))
+ x509_USER_PROXY = CoGProperties.getDefault().getProxyFile();
+
+ if (x509_USER_PROXY == null)
+ throw new SecurityException("could not get credential; no location defined");
+
+ ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance();
+
+ // file...load file into a buffer
+ try {
+ File f = new File(x509_USER_PROXY);
+ byte[] data = new byte[(int) f.length()];
+ FileInputStream in = new FileInputStream(f);
+ // read in the credential data
+ in.read(data);
+ in.close();
+ return manager.createCredential(data, ExtendedGSSCredential.IMPEXP_OPAQUE, credentialLifetime, null, // use
+ // default
+ // mechanism
+ // -
+ // GSI
+ GSSCredential.INITIATE_AND_ACCEPT);
+ } catch (Throwable t) {
+ throw new SecurityException("could not get credential from " + x509_USER_PROXY, t);
+ }
+ }
+
+ public boolean isEstablished() {
+ // this must check to see if the call returned GSS_S_COMPLETE
+ if (context != null){
+ return context.isEstablished();
+ }
+ return false;
+ }
+
+ public byte[] init(byte[] token, int s, int l) throws JSchException {
+ try {
+ if (context != null){
+ return context.initSecContext(token, s, l);
+ }else {
+ throw new JSchException("Context is null..");
+ }
+ } catch (GSSException ex) {
+ throw new JSchException(ex.toString());
+ }
+ }
+
+ public byte[] getMIC(byte[] message, int s, int l) {
+ try {
+ MessageProp prop = new MessageProp(0, false);
+ return context.getMIC(message, s, l, prop);
+ } catch (GSSException ex) {
+ logger.error(ex.getMessage(), ex);
+ return null;
+ }
+ }
+
+ public void dispose() {
+ try {
+ context.dispose();
+ } catch (GSSException ex) {
+ }
+ }
+
+ public void setCredential(GSSCredential credential) {
+ this.credential = credential;
+ }
+
+ public GSSCredential getCredential() {
+ return credential;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Cluster.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Cluster.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Cluster.java
new file mode 100644
index 0000000..beb5b37
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Cluster.java
@@ -0,0 +1,162 @@
+/*
+ *
+ * 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.gfac.ssh.api;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.airavata.gfac.ssh.api.job.JobDescriptor;
+import org.apache.airavata.gfac.ssh.impl.JobStatus;
+
+import com.jcraft.jsch.Session;
+
+/**
+ * This interface represents a Cluster machine
+ * End users of the API can implement this and come up with their own
+ * implementations, but mostly this interface is for internal usage.
+ */
+public interface Cluster {
+
+ /**
+ * This will submit a job to the cluster with a given pbs file and some parameters
+ *
+ * @param pbsFilePath path of the pbs file
+ * @param workingDirectory working directory where pbs should has to copy
+ * @return jobId after successful job submission
+ * @throws SSHApiException throws exception during error
+ */
+ public String submitBatchJobWithScript(String pbsFilePath, String workingDirectory) throws SSHApiException;
+
+ /**
+ * This will submit the given job and not performing any monitoring
+ *
+ * @param jobDescriptor job descriptor to submit to cluster, this contains all the parameter
+ * @return jobID after successful job submission.
+ * @throws SSHApiException throws exception during error
+ */
+ public String submitBatchJob(JobDescriptor jobDescriptor) throws SSHApiException;
+
+ /**
+ * This will copy the localFile to remoteFile location in configured cluster
+ *
+ * @param remoteFile remote file location, this can be a directory too
+ * @param localFile local file path of the file which needs to copy to remote location
+ * @throws SSHApiException throws exception during error
+ */
+ public void scpTo(String remoteFile, String localFile) throws SSHApiException;
+
+ /**
+ * This will copy a remote file in path rFile to local file lFile
+ * @param remoteFile remote file path, this has to be a full qualified path
+ * @param localFile This is the local file to copy, this can be a directory too
+ * @throws SSHApiException
+ */
+ public void scpFrom(String remoteFile, String localFile) throws SSHApiException;
+
+ /**
+ * This will copy a remote file in path rFile to local file lFile
+ * @param remoteFile remote file path, this has to be a full qualified path
+ * @param localFile This is the local file to copy, this can be a directory too
+ * @throws SSHApiException
+ */
+ public void scpThirdParty(String remoteFileSorce, String remoteFileTarget) throws SSHApiException;
+
+ /**
+ * This will create directories in computing resources
+ * @param directoryPath the full qualified path for the directory user wants to create
+ * @throws SSHApiException throws during error
+ */
+ public void makeDirectory(String directoryPath) throws SSHApiException;
+
+
+ /**
+ * This will get the job description of a job which is there in the cluster
+ * if jbo is not available with the given ID it returns
+ * @param jobID jobId has to pass
+ * @return Returns full job description of the job which submitted successfully
+ * @throws SSHApiException throws exception during error
+ */
+ public JobDescriptor getJobDescriptorById(String jobID) throws SSHApiException;
+
+ /**
+ * This will delete the given job from the queue
+ *
+ * @param jobID jobId of the job which user wants to delete
+ * @return return the description of the deleted job
+ * @throws SSHApiException throws exception during error
+ */
+ public JobDescriptor cancelJob(String jobID) throws SSHApiException;
+
+ /**
+ * This will get the job status of the the job associated with this jobId
+ *
+ * @param jobID jobId of the job user want to get the status
+ * @return job status of the given jobID
+ * @throws SSHApiException throws exception during error
+ */
+ public JobStatus getJobStatus(String jobID) throws SSHApiException;
+ /**
+ * This will get the job status of the the job associated with this jobId
+ *
+ * @param jobName jobName of the job user want to get the status
+ * @return jobId of the given jobName
+ * @throws SSHApiException throws exception during error
+ */
+ public String getJobIdByJobName(String jobName, String userName) throws SSHApiException;
+
+ /**
+ * This method can be used to poll the jobstatuses based on the given
+ * user but we should pass the jobID list otherwise we will get unwanted
+ * job statuses which submitted by different middleware outside apache
+ * airavata with the same uername which we are not considering
+ * @param userName userName of the jobs which required to get the status
+ * @param jobIDs precises set of jobIDs
+ * @return
+ */
+ public void getJobStatuses(String userName,Map<String,JobStatus> jobIDs)throws SSHApiException;
+ /**
+ * This will list directories in computing resources
+ * @param directoryPath the full qualified path for the directory user wants to create
+ * @throws SSHApiException throws during error
+ */
+ public List<String> listDirectory(String directoryPath) throws SSHApiException;
+
+ /**
+ * This method can be used to get created ssh session
+ * to reuse the created session.
+ * @throws SSHApiException
+ */
+ public Session getSession() throws SSHApiException;
+
+ /**
+ * This method can be used to close the connections initialized
+ * to handle graceful shutdown of the system
+ * @throws SSHApiException
+ */
+ public void disconnect() throws SSHApiException;
+
+ /**
+ * This gives the server Info
+ * @return
+ */
+ public ServerInfo getServerInfo();
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java
new file mode 100644
index 0000000..024c53d
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java
@@ -0,0 +1,278 @@
+/*
+ *
+ * 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.gfac.ssh.api;
+
+import com.jcraft.jsch.*;
+import org.apache.airavata.gfac.ssh.api.authentication.*;
+import org.apache.airavata.gfac.ssh.config.ConfigReader;
+import org.apache.airavata.gfac.ssh.jsch.ExtendedJSch;
+import org.apache.airavata.gfac.ssh.util.SSHAPIUIKeyboardInteractive;
+import org.apache.airavata.gfac.ssh.util.SSHKeyPasswordHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This is a generic class which take care of command execution
+ * in a shell, this is used through out the other places of the API.
+ */
+public class CommandExecutor {
+ static {
+ JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gfac.ssh.GSSContextX509");
+ JSch.setConfig("userauth.gssapi-with-mic", "com.jcraft.jsch.UserAuthGSSAPIWithMICGSSCredentials");
+ JSch jSch = new JSch();
+ }
+
+ private static final Logger log = LoggerFactory.getLogger(CommandExecutor.class);
+ public static final String X509_CERT_DIR = "X509_CERT_DIR";
+
+ /**
+ * This will execute the given command with given session and session is not closed at the end.
+ *
+ * @param commandInfo
+ * @param session
+ * @param commandOutput
+ * @throws SSHApiException
+ */
+ public static Session executeCommand(CommandInfo commandInfo, Session session,
+ CommandOutput commandOutput) throws SSHApiException {
+
+ String command = commandInfo.getCommand();
+
+ Channel channel = null;
+ try {
+ if (!session.isConnected()) {
+ session.connect();
+ }
+ channel = session.openChannel("exec");
+ ((ChannelExec) channel).setCommand(command);
+ } catch (JSchException e) {
+// session.disconnect();
+
+ throw new SSHApiException("Unable to execute command - ", e);
+ }
+
+ channel.setInputStream(null);
+ ((ChannelExec) channel).setErrStream(commandOutput.getStandardError());
+ try {
+ channel.connect();
+ } catch (JSchException e) {
+
+ channel.disconnect();
+// session.disconnect();
+ throw new SSHApiException("Unable to retrieve command output. Command - " + command, e);
+ }
+
+
+ commandOutput.onOutput(channel);
+ //Only disconnecting the channel, session can be reused
+ channel.disconnect();
+ return session;
+ }
+
+ /**
+ * This will not reuse any session, it will create the session and close it at the end
+ *
+ * @param commandInfo Encapsulated information about command. E.g :- executable name
+ * parameters etc ...
+ * @param serverInfo The SSHing server information.
+ * @param authenticationInfo Security data needs to be communicated with remote server.
+ * @param commandOutput The output of the command.
+ * @param configReader configuration required for ssh/gshissh connection
+ * @throws SSHApiException throw exception when error occurs
+ */
+ public static void executeCommand(CommandInfo commandInfo, ServerInfo serverInfo,
+ AuthenticationInfo authenticationInfo,
+ CommandOutput commandOutput, ConfigReader configReader) throws SSHApiException {
+
+ if (authenticationInfo instanceof GSIAuthenticationInfo) {
+ System.setProperty(X509_CERT_DIR, (String) ((GSIAuthenticationInfo)authenticationInfo).getProperties().
+ get("X509_CERT_DIR"));
+ }
+
+
+ JSch jsch = new ExtendedJSch();
+
+ log.debug("Connecting to server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " with user name - "
+ + serverInfo.getUserName());
+
+ Session session;
+
+ try {
+ session = jsch.getSession(serverInfo.getUserName(), serverInfo.getHost(), serverInfo.getPort());
+ } catch (JSchException 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 = 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);
+ }
+
+ String command = commandInfo.getCommand();
+
+ Channel channel;
+ try {
+ channel = session.openChannel("exec");
+ ((ChannelExec) channel).setCommand(command);
+ } catch (JSchException e) {
+// session.disconnect();
+
+ throw new SSHApiException("Unable to execute command - " + command +
+ " on server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+ " connecting user name - "
+ + serverInfo.getUserName(), e);
+ }
+
+
+ channel.setInputStream(null);
+ ((ChannelExec) channel).setErrStream(commandOutput.getStandardError());
+
+ try {
+ channel.connect();
+ } catch (JSchException e) {
+
+ channel.disconnect();
+// session.disconnect();
+
+ throw new SSHApiException("Unable to retrieve command output. Command - " + command +
+ " on server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
+ " connecting user name - "
+ + serverInfo.getUserName(), e);
+ }
+
+ commandOutput.onOutput(channel);
+
+ channel.disconnect();
+// session.disconnect();
+ }
+
+ private static void logDebug(String message) {
+ if (log.isDebugEnabled()) {
+ log.debug(message);
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandInfo.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandInfo.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandInfo.java
new file mode 100644
index 0000000..e6797ce
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandInfo.java
@@ -0,0 +1,34 @@
+package org.apache.airavata.gfac.ssh.api;/*
+ *
+ * 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.
+ *
+ */
+
+/**
+ * Encapsulates information about
+ */
+public interface CommandInfo {
+
+ /**
+ * Gets the executable command as a string.
+ * @return String encoded command. Should be able to execute
+ * directly on remote shell. Should includes appropriate parameters.
+ */
+ String getCommand();
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandOutput.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandOutput.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandOutput.java
new file mode 100644
index 0000000..f275ff0
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandOutput.java
@@ -0,0 +1,49 @@
+package org.apache.airavata.gfac.ssh.api;/*
+ *
+ * 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.
+ *
+ */
+
+
+import com.jcraft.jsch.Channel;
+
+import java.io.OutputStream;
+
+/**
+ * Output of a certain command. TODO rethink
+ */
+public interface CommandOutput {
+
+ /**
+ * Gets the output of the command as a stream.
+ * @param channel Command output as a stream.
+ */
+ void onOutput(Channel channel);
+
+ /**
+ * Gets standard error as a output stream.
+ * @return Command error as a stream.
+ */
+ OutputStream getStandardError();
+
+ /**
+ * The command exit code.
+ * @param code The program exit code
+ */
+ void exitCode(int code);
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Core.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Core.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Core.java
new file mode 100644
index 0000000..67dd043
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Core.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.gfac.ssh.api;
+
+import org.apache.airavata.gfac.ssh.api.job.JobDescriptor;
+
+/**
+ * This represents a CPU core of a machine in the cluster
+ */
+public class Core {
+ private JobDescriptor job;
+ private String id;
+
+ public Core(String id) {
+ this.id = id;
+ this.job = null;
+ }
+
+ /**
+ * @return core's id
+ */
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return job running on the core
+ */
+ public JobDescriptor getJob() {
+ return job;
+ }
+
+ public void setJob(JobDescriptor job) {
+ this.job = job;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Node.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Node.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Node.java
new file mode 100644
index 0000000..1515f39
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Node.java
@@ -0,0 +1,104 @@
+/*
+ *
+ * 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.gfac.ssh.api;
+
+import java.util.HashMap;
+
+public class Node {
+ private String Name;
+ private Core[] Cores;
+ private String state;
+ private HashMap<String, String> status;
+ private String np;
+ private String ntype;
+
+ /**
+ * @return the machine's name
+ */
+ public String getName() {
+ return Name;
+ }
+
+ public void setName(String Name) {
+ this.Name = Name;
+ }
+
+ /**
+ * @return machine cores as an array
+ */
+ public Core[] getCores() {
+ return Cores;
+ }
+
+ public void setCores(Core[] Cores) {
+ this.Cores = Cores;
+ }
+
+
+ /**
+ * @return the machine state
+ */
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ /**
+ * @return the status
+ */
+ public HashMap<String, String> getStatus() {
+ return status;
+ }
+
+ public void setStatus(HashMap<String, String> status) {
+ this.setStatus(status);
+ }
+
+
+ /**
+ * @return the number of cores in the machine
+ */
+ public String getNp() {
+ return np;
+ }
+
+
+ public void setNp(String np) {
+ this.np = np;
+ }
+
+ /**
+ * @return the ntype of the machine
+ */
+ public String getNtype() {
+ return ntype;
+ }
+
+
+ public void setNtype(String ntype) {
+ this.ntype = ntype;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/SSHApiException.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/SSHApiException.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/SSHApiException.java
new file mode 100644
index 0000000..f78825b
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/SSHApiException.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.gfac.ssh.api;
+
+/**
+ * An exception class to wrap SSH command execution related errors.
+ */
+public class SSHApiException extends Exception {
+
+ public SSHApiException(String message) {
+ super(message);
+ }
+
+ public SSHApiException(String message, Exception e) {
+ super(message, e);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/ServerInfo.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/ServerInfo.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/ServerInfo.java
new file mode 100644
index 0000000..d3c2160
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/ServerInfo.java
@@ -0,0 +1,65 @@
+package org.apache.airavata.gfac.ssh.api;/*
+ *
+ * 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.
+ *
+ */
+
+/**
+ * Encapsulate server information.
+ */
+public class ServerInfo {
+
+ private String host;
+ private String userName;
+ private int port = 22;
+
+ public ServerInfo(String userName, String host) {
+ this.userName = userName;
+ this.host = host;
+ }
+
+ public ServerInfo(String userName,String host, int port) {
+ this.host = host;
+ this.userName = userName;
+ this.port = port;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/AuthenticationInfo.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/AuthenticationInfo.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/AuthenticationInfo.java
new file mode 100644
index 0000000..6b4e913
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/AuthenticationInfo.java
@@ -0,0 +1,32 @@
+package org.apache.airavata.gfac.ssh.api.authentication;/*
+ *
+ * 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.
+ *
+ */
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 11:25 AM
+ */
+
+/**
+ * An empty interface that represents authentication data to the API.
+ */
+public interface AuthenticationInfo {
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/GSIAuthenticationInfo.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/GSIAuthenticationInfo.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/GSIAuthenticationInfo.java
new file mode 100644
index 0000000..1f327f0
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/GSIAuthenticationInfo.java
@@ -0,0 +1,43 @@
+package org.apache.airavata.gfac.ssh.api.authentication;/*
+ *
+ * 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.
+ *
+ */
+
+import org.ietf.jgss.GSSCredential;
+
+import java.util.Properties;
+
+/**
+ * Authentication data. Could be MyProxy user name, password, could be GSSCredentials
+ * or could be SSH keys.
+ */
+public abstract class GSIAuthenticationInfo implements AuthenticationInfo {
+
+ public Properties properties = new Properties();
+
+ public abstract GSSCredential getCredentials() throws SecurityException;
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHKeyAuthentication.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHKeyAuthentication.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHKeyAuthentication.java
new file mode 100644
index 0000000..ebd79f2
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHKeyAuthentication.java
@@ -0,0 +1,46 @@
+package org.apache.airavata.gfac.ssh.api.authentication;/*
+ *
+ * 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.
+ *
+ */
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 2:39 PM
+ */
+
+/**
+ * Abstracts out common methods for SSH key authentication.
+ */
+public interface SSHKeyAuthentication extends AuthenticationInfo {
+
+ /**
+ * This is needed only if private key and public keys are encrypted.
+ * If they are not encrypted we can just return null.
+ * @return User should return pass phrase if keys are encrypted. If not null.
+ */
+ String getPassPhrase();
+
+ /**
+ * Callback with the banner message. API user can get hold of banner message
+ * by implementing this method.
+ * @param message The banner message.
+ */
+ void bannerMessage(String message);
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPasswordAuthentication.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPasswordAuthentication.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPasswordAuthentication.java
new file mode 100644
index 0000000..fd884f8
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPasswordAuthentication.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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.gfac.ssh.api.authentication;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 11:22 AM
+ */
+
+/**
+ * Password authentication for vanilla SSH.
+ */
+public interface SSHPasswordAuthentication extends AuthenticationInfo {
+
+ /**
+ * Gets the password for given host name and given user name.
+ * @param userName The connecting user name name.
+ * @param hostName The connecting host.
+ * @return Password for the given user.
+ */
+ String getPassword(String userName, String hostName);
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java
new file mode 100644
index 0000000..dcedfec
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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.gfac.ssh.api.authentication;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 9:48 AM
+ */
+
+
+/**
+ * Public key authentication for vanilla SSH.
+ * The public key and private key are returned as byte arrays. Useful when we store private key/public key
+ * in a secure storage such as credential store. API user should implement this.
+ */
+public interface SSHPublicKeyAuthentication extends SSHKeyAuthentication {
+
+ /**
+ * Gets the public key as byte array.
+ * @param userName The user who is trying to SSH
+ * @param hostName The host which user wants to connect to.
+ * @return The public key as a byte array.
+ */
+ byte[] getPrivateKey(String userName, String hostName);
+
+ /**
+ * Gets the private key as byte array.
+ * @param userName The user who is trying to SSH
+ * @param hostName The host which user wants to connect to.
+ * @return The private key as a byte array.
+ */
+ byte[] getPublicKey(String userName, String hostName);
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java
new file mode 100644
index 0000000..e22b9af
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java
@@ -0,0 +1,52 @@
+package org.apache.airavata.gfac.ssh.api.authentication;/*
+ *
+ * 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.
+ *
+ */
+
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/4/13
+ * Time: 9:52 AM
+ */
+
+/**
+ * Public key authentication for vanilla SSH.
+ * The public key and private key stored files are returned. API user should implement this.
+ */
+public interface SSHPublicKeyFileAuthentication extends SSHKeyAuthentication {
+
+ /**
+ * The file which contains the public key.
+ * @param userName The user who is trying to SSH
+ * @param hostName The host which user wants to connect to.
+ * @return The name of the file which contains the public key.
+ */
+ String getPublicKeyFile(String userName, String hostName);
+
+ /**
+ * The file which contains the public key.
+ * @param userName The user who is trying to SSH
+ * @param hostName The host which user wants to connect to.
+ * @return The name of the file which contains the private key.
+ */
+ String getPrivateKeyFile(String userName, String hostName);
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobDescriptor.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobDescriptor.java
new file mode 100644
index 0000000..7e936ec
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobDescriptor.java
@@ -0,0 +1,473 @@
+/*
+ *
+ * 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.gfac.ssh.api.job;
+
+import org.apache.airavata.gfac.ssh.api.CommandOutput;
+import org.apache.airavata.gfac.ssh.util.CommonUtils;
+import org.apache.airavata.gfac.ssh.x2012.x12.*;
+import org.apache.xmlbeans.XmlException;
+
+import java.util.List;
+
+/**
+ * This class define a job with required parameters, based on this configuration API is generating a Pbs script and
+ * submit the job to the computing resource
+ */
+public class JobDescriptor {
+
+ private JobDescriptorDocument jobDescriptionDocument;
+
+
+ public JobDescriptor() {
+ jobDescriptionDocument = JobDescriptorDocument.Factory.newInstance();
+ jobDescriptionDocument.addNewJobDescriptor();
+ }
+
+ public JobDescriptor(JobDescriptorDocument jobDescriptorDocument) {
+ this.jobDescriptionDocument = jobDescriptorDocument;
+ }
+
+
+ public JobDescriptor(CommandOutput commandOutput) {
+ jobDescriptionDocument = JobDescriptorDocument.Factory.newInstance();
+ jobDescriptionDocument.addNewJobDescriptor();
+ }
+
+
+ public String toXML() {
+ return jobDescriptionDocument.xmlText();
+ }
+
+ public JobDescriptorDocument getJobDescriptorDocument() {
+ return this.jobDescriptionDocument;
+ }
+
+ /**
+ * With new app catalog thrift object integration, we don't use this
+ * @param xml
+ * @return
+ * @throws XmlException
+ */
+ @Deprecated
+ public static JobDescriptor fromXML(String xml)
+ throws XmlException {
+ JobDescriptorDocument parse = JobDescriptorDocument.Factory
+ .parse(xml);
+ JobDescriptor jobDescriptor = new JobDescriptor(parse);
+ return jobDescriptor;
+ }
+
+
+ //todo write bunch of setter getters to set and get jobdescription parameters
+ public void setWorkingDirectory(String workingDirectory) {
+ this.getJobDescriptorDocument().getJobDescriptor().setWorkingDirectory(workingDirectory);
+ }
+
+ public String getWorkingDirectory() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getWorkingDirectory();
+ }
+
+ public void setShellName(String shellName) {
+ this.getJobDescriptorDocument().getJobDescriptor().setShellName(shellName);
+ }
+
+ public void setJobName(String name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setJobName(name);
+ }
+
+ public void setExecutablePath(String name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setExecutablePath(name);
+ }
+
+ public void setAllEnvExport(boolean name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setAllEnvExport(name);
+ }
+
+ public void setMailOptions(String name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setMailOptions(name);
+ }
+
+ public void setStandardOutFile(String name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setStandardOutFile(name);
+ }
+
+ public void setStandardErrorFile(String name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setStandardErrorFile(name);
+ }
+
+ public void setNodes(int name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setNodes(name);
+ }
+
+ public void setProcessesPerNode(int name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setProcessesPerNode(name);
+ }
+
+ public String getOutputDirectory() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getOutputDirectory();
+ }
+
+ public String getInputDirectory() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getInputDirectory();
+ }
+ public void setOutputDirectory(String name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setOutputDirectory(name);
+ }
+
+ public void setInputDirectory(String name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setInputDirectory(name);
+ }
+
+ /**
+ * Users can pass the minute count for maxwalltime
+ * @param minutes
+ */
+ public void setMaxWallTime(String minutes) {
+ this.getJobDescriptorDocument().getJobDescriptor().setMaxWallTime(
+ CommonUtils.maxWallTimeCalculator(Integer.parseInt(minutes)));
+
+ }
+
+
+ public void setMaxWallTimeForLSF(String minutes) {
+ this.getJobDescriptorDocument().getJobDescriptor().setMaxWallTime(
+ CommonUtils.maxWallTimeCalculatorForLSF(Integer.parseInt(minutes)));
+
+ }
+ public void setAcountString(String name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setAcountString(name);
+ }
+
+ public void setInputValues(List<String> inputValue) {
+ InputList inputList = this.getJobDescriptorDocument().getJobDescriptor().addNewInputs();
+ inputList.setInputArray(inputValue.toArray(new String[inputValue.size()]));
+ }
+
+ public void setJobID(String jobID) {
+ this.getJobDescriptorDocument().getJobDescriptor().setJobID(jobID);
+ }
+
+ public void setQueueName(String queueName) {
+ this.getJobDescriptorDocument().getJobDescriptor().setQueueName(queueName);
+ }
+
+ public void setStatus(String queueName) {
+ this.getJobDescriptorDocument().getJobDescriptor().setStatus(queueName);
+ }
+
+ public void setAfterAnyList(String[] afterAnyList) {
+ AfterAnyList afterAny = this.getJobDescriptorDocument().getJobDescriptor().addNewAfterAny();
+ afterAny.setAfterAnyArray(afterAnyList);
+ }
+
+ public void setAfterOKList(String[] afterOKList) {
+ AfterOKList afterAnyList = this.getJobDescriptorDocument().getJobDescriptor().addNewAfterOKList();
+ afterAnyList.setAfterOKListArray(afterOKList);
+ }
+ public void setCTime(String cTime) {
+ this.getJobDescriptorDocument().getJobDescriptor().setCTime(cTime);
+ }
+ public void setQTime(String qTime) {
+ this.getJobDescriptorDocument().getJobDescriptor().setQTime(qTime);
+ }
+ public void setMTime(String mTime) {
+ this.getJobDescriptorDocument().getJobDescriptor().setMTime(mTime);
+ }
+ public void setSTime(String sTime) {
+ this.getJobDescriptorDocument().getJobDescriptor().setSTime(sTime);
+ }
+ public void setCompTime(String compTime) {
+ this.getJobDescriptorDocument().getJobDescriptor().setCompTime(compTime);
+ }
+ public void setOwner(String owner) {
+ this.getJobDescriptorDocument().getJobDescriptor().setOwner(owner);
+ }
+ public void setExecuteNode(String executeNode) {
+ this.getJobDescriptorDocument().getJobDescriptor().setExecuteNode(executeNode);
+ }
+ public void setEllapsedTime(String ellapsedTime) {
+ this.getJobDescriptorDocument().getJobDescriptor().setEllapsedTime(ellapsedTime);
+ }
+
+ public void setUsedCPUTime(String usedCPUTime) {
+ this.getJobDescriptorDocument().getJobDescriptor().setUsedCPUTime(usedCPUTime);
+ }
+ public void setCPUCount(int usedCPUTime) {
+ this.getJobDescriptorDocument().getJobDescriptor().setCpuCount(usedCPUTime);
+ }
+ public void setUsedMemory(String usedMemory) {
+ this.getJobDescriptorDocument().getJobDescriptor().setUsedMem(usedMemory);
+ }
+ public void setVariableList(String variableList) {
+ this.getJobDescriptorDocument().getJobDescriptor().setVariableList(variableList);
+ }
+ public void setSubmitArgs(String submitArgs) {
+ this.getJobDescriptorDocument().getJobDescriptor().setSubmitArgs(submitArgs);
+ }
+
+ public void setPreJobCommands(String[] commands){
+ if(this.getJobDescriptorDocument().getJobDescriptor().getPreJobCommands() == null){
+ this.getJobDescriptorDocument().getJobDescriptor().addNewPreJobCommands();
+ }
+ this.getJobDescriptorDocument().getJobDescriptor().getPreJobCommands().setCommandArray(commands);
+ }
+
+ public void setPostJobCommands(String[] commands){
+ if(this.getJobDescriptorDocument().getJobDescriptor().getPostJobCommands() == null){
+ this.getJobDescriptorDocument().getJobDescriptor().addNewPostJobCommands();
+ }
+ this.getJobDescriptorDocument().getJobDescriptor().getPostJobCommands().setCommandArray(commands);
+ }
+
+ public void setModuleLoadCommands(String[] commands) {
+ if (this.getJobDescriptorDocument().getJobDescriptor().getModuleLoadCommands() == null) {
+ this.getJobDescriptorDocument().getJobDescriptor().addNewModuleLoadCommands();
+ }
+ this.getJobDescriptorDocument().getJobDescriptor().getModuleLoadCommands().setCommandArray(commands);
+ }
+
+ public void addModuleLoadCommands(String command) {
+ if (this.getJobDescriptorDocument().getJobDescriptor().getModuleLoadCommands() == null) {
+ this.getJobDescriptorDocument().getJobDescriptor().addNewModuleLoadCommands();
+ }
+ this.getJobDescriptorDocument().getJobDescriptor().getModuleLoadCommands().addCommand(command);
+ }
+
+ public void addPreJobCommand(String command){
+ if(this.getJobDescriptorDocument().getJobDescriptor().getPreJobCommands() == null){
+ this.getJobDescriptorDocument().getJobDescriptor().addNewPreJobCommands();
+ }
+ this.getJobDescriptorDocument().getJobDescriptor().getPreJobCommands().addCommand(command);
+ }
+
+ public void addPostJobCommand(String command){
+ if(this.getJobDescriptorDocument().getJobDescriptor().getPostJobCommands() == null){
+ this.getJobDescriptorDocument().getJobDescriptor().addNewPostJobCommands();
+ }
+ this.getJobDescriptorDocument().getJobDescriptor().getPostJobCommands().addCommand(command);
+ }
+
+ public void setPartition(String partition){
+ this.getJobDescriptorDocument().getJobDescriptor().setPartition(partition);
+ }
+
+ public void setUserName(String userName){
+ this.getJobDescriptorDocument().getJobDescriptor().setUserName(userName);
+ }
+ public void setNodeList(String nodeList){
+ this.getJobDescriptorDocument().getJobDescriptor().setNodeList(nodeList);
+ }
+ public void setJobSubmitter(String jobSubmitter){
+ this.getJobDescriptorDocument().getJobDescriptor().setJobSubmitterCommand(jobSubmitter);
+ }
+ public String getNodeList(){
+ return this.getJobDescriptorDocument().getJobDescriptor().getNodeList();
+ }
+ public String getExecutablePath() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getExecutablePath();
+ }
+
+ public boolean getAllEnvExport() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getAllEnvExport();
+ }
+
+ public String getMailOptions() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getMailOptions();
+ }
+
+ public String getStandardOutFile() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getStandardOutFile();
+ }
+
+ public String getStandardErrorFile() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getStandardErrorFile();
+ }
+
+ public int getNodes(int name) {
+ return this.getJobDescriptorDocument().getJobDescriptor().getNodes();
+ }
+
+ public int getCPUCount(int name) {
+ return this.getJobDescriptorDocument().getJobDescriptor().getCpuCount();
+ }
+
+ public int getProcessesPerNode() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getProcessesPerNode();
+ }
+
+ public String getMaxWallTime() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getMaxWallTime();
+ }
+
+ public String getAcountString() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getAcountString();
+ }
+
+ public String[] getInputValues() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getInputs().getInputArray();
+ }
+
+ public String getJobID() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getJobID();
+ }
+
+ public String getQueueName() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getQueueName();
+ }
+
+ public String getStatus() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getStatus();
+ }
+
+ public String[] getAfterAnyList() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getAfterAny().getAfterAnyArray();
+ }
+
+ public String[] getAfterOKList() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getAfterOKList().getAfterOKListArray();
+ }
+ public String getCTime() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getCTime();
+ }
+ public String getQTime() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getQTime();
+ }
+ public String getMTime() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getMTime();
+ }
+ public String getSTime() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getSTime();
+ }
+ public String getCompTime() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getCompTime();
+ }
+ public String getOwner() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getOwner();
+ }
+ public String getExecuteNode() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getExecuteNode();
+ }
+ public String getEllapsedTime() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getEllapsedTime();
+ }
+
+ public String getUsedCPUTime() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getUsedCPUTime();
+ }
+
+ public String getUsedMemory() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getUsedMem();
+ }
+ public void getShellName() {
+ this.getJobDescriptorDocument().getJobDescriptor().getShellName();
+ }
+
+ public String getJobName() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getJobName();
+ }
+
+ public String getJobId() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getJobID();
+ }
+
+
+ public String getVariableList() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getJobID();
+ }
+ public String getSubmitArgs() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getJobID();
+ }
+
+ public String[] getPostJobCommands(){
+ if(this.getJobDescriptorDocument().getJobDescriptor().getPostJobCommands() != null) {
+ return this.getJobDescriptorDocument().getJobDescriptor().getPostJobCommands().getCommandArray();
+ }
+ return null;
+ }
+
+ public String[] getModuleCommands() {
+ if (this.getJobDescriptorDocument().getJobDescriptor().getModuleLoadCommands() != null) {
+ return this.getJobDescriptorDocument().getJobDescriptor().getModuleLoadCommands().getCommandArray();
+ }
+ return null;
+ }
+
+ public String[] getPreJobCommands(){
+ if(this.getJobDescriptorDocument().getJobDescriptor().getPreJobCommands() != null) {
+ return this.getJobDescriptorDocument().getJobDescriptor().getPreJobCommands().getCommandArray();
+ }
+ return null;
+ }
+
+ public String getJobSubmitterCommand(){
+ return this.getJobDescriptorDocument().getJobDescriptor().getJobSubmitterCommand();
+ }
+
+ public String getPartition(){
+ return this.getJobDescriptorDocument().getJobDescriptor().getPartition();
+ }
+
+ public String getUserName(){
+ return this.getJobDescriptorDocument().getJobDescriptor().getUserName();
+ }
+
+ public void setCallBackIp(String ip){
+ this.jobDescriptionDocument.getJobDescriptor().setCallBackIp(ip);
+ }
+
+ public void setCallBackPort(String ip){
+ this.jobDescriptionDocument.getJobDescriptor().setCallBackPort(ip);
+ }
+
+
+ public String getCallBackIp(){
+ return this.jobDescriptionDocument.getJobDescriptor().getCallBackIp();
+ }
+ public String getCallBackPort(){
+ return this.jobDescriptionDocument.getJobDescriptor().getCallBackPort();
+ }
+
+ public void setMailType(String emailType) {
+ this.getJobDescriptorDocument().getJobDescriptor().setMailType(emailType);
+ }
+
+ public String getMailType() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getMailType();
+ }
+ public void setMailAddress(String emailAddress) {
+ this.getJobDescriptorDocument().getJobDescriptor().setMailAddress(emailAddress);
+ }
+
+ public String getMailAddress() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getMailAddress();
+ }
+
+ public String getChassisName() {
+ return this.getJobDescriptorDocument().getJobDescriptor().getChassisName();
+ }
+
+ public void setChassisName(String chassisName){
+ this.getJobDescriptorDocument().getJobDescriptor().setChassisName(chassisName);
+ }
+
+
+}
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobManagerConfiguration.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobManagerConfiguration.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobManagerConfiguration.java
new file mode 100644
index 0000000..d58a994
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobManagerConfiguration.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.gfac.ssh.api.job;
+
+import org.apache.airavata.gfac.ssh.impl.RawCommandInfo;
+
+public interface JobManagerConfiguration {
+
+ public RawCommandInfo getCancelCommand(String jobID);
+
+ public String getJobDescriptionTemplateName();
+
+ public RawCommandInfo getMonitorCommand(String jobID);
+
+ public RawCommandInfo getUserBasedMonitorCommand(String userName);
+
+ public RawCommandInfo getJobIdMonitorCommand(String jobName , String userName);
+
+ public String getScriptExtension();
+
+ public RawCommandInfo getSubmitCommand(String workingDirectory, String pbsFilePath);
+
+ public OutputParser getParser();
+
+ public String getInstalledPath();
+
+ public String getBaseCancelCommand();
+
+ public String getBaseMonitorCommand();
+
+ public String getBaseSubmitCommand();
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobType.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobType.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobType.java
new file mode 100644
index 0000000..556f4ef
--- /dev/null
+++ b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/JobType.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.gfac.ssh.api.job;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahirugunathilake
+ * Date: 8/22/13
+ * Time: 7:19 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public enum JobType {
+ SERIAL, SINGLE, MPI, MULTIPLE, CONDOR
+}