You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2013/10/07 17:05:40 UTC
svn commit: r1529931 - in /airavata/sandbox/gsissh/src/main:
java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java
java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java
java/org/apache/airavata/gsi/ssh/util/SSHUtils.java
resources/PBSTemplate.xslt
Author: lahiru
Date: Mon Oct 7 15:05:40 2013
New Revision: 1529931
URL: http://svn.apache.org/r1529931
Log:
new changes to get the vanilassh wroking with br2.
Modified:
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java
airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt
Modified: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java?rev=1529931&r1=1529930&r2=1529931&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java Mon Oct 7 15:05:40 2013
@@ -119,8 +119,7 @@ public class JobDescriptor {
* @param minutes
*/
public void setMaxWallTime(String minutes) {
- this.getJobDescriptorDocument().getJobDescriptor().setMaxWallTime(
- CommonUtils.maxWallTimeCalculator(Integer.getInteger(minutes)));
+ this.getJobDescriptorDocument().getJobDescriptor().setMaxWallTime(minutes);
}
Modified: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java?rev=1529931&r1=1529930&r2=1529931&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/PBSCluster.java Mon Oct 7 15:05:40 2013
@@ -78,12 +78,14 @@ public class PBSCluster implements Clust
this.authenticationInfo = authenticationInfo;
- System.setProperty(X509_CERT_DIR, (String) ((GSIAuthenticationInfo)authenticationInfo).getProperties().
- get(X509_CERT_DIR));
+ if (authenticationInfo instanceof GSIAuthenticationInfo) {
+ System.setProperty(X509_CERT_DIR, (String) ((GSIAuthenticationInfo) authenticationInfo).getProperties().
+ get("X509_CERT_DIR"));
+ }
- if(installedPath.endsWith("/")){
+ if (installedPath.endsWith("/")) {
this.installedPath = installedPath;
- }else {
+ } else {
this.installedPath = installedPath + "/";
}
@@ -125,7 +127,7 @@ public class PBSCluster implements Clust
} else if (authenticationInfo instanceof SSHPublicKeyFileAuthentication) {
SSHPublicKeyFileAuthentication sshPublicKeyFileAuthentication
- = (SSHPublicKeyFileAuthentication)authenticationInfo;
+ = (SSHPublicKeyFileAuthentication) authenticationInfo;
String privateKeyFile = sshPublicKeyFileAuthentication.
getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
@@ -159,14 +161,14 @@ public class PBSCluster implements Clust
// Set the user info
SSHKeyPasswordHandler sshKeyPasswordHandler
- = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo);
+ = new SSHKeyPasswordHandler((SSHKeyAuthentication) authenticationInfo);
session.setUserInfo(sshKeyPasswordHandler);
} else if (authenticationInfo instanceof SSHPublicKeyAuthentication) {
SSHPublicKeyAuthentication sshPublicKeyAuthentication
- = (SSHPublicKeyAuthentication)authenticationInfo;
+ = (SSHPublicKeyAuthentication) authenticationInfo;
Identity identityFile;
@@ -192,7 +194,7 @@ public class PBSCluster implements Clust
// Set the user info
SSHKeyPasswordHandler sshKeyPasswordHandler
- = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo);
+ = new SSHKeyPasswordHandler((SSHKeyAuthentication) authenticationInfo);
session.setUserInfo(sshKeyPasswordHandler);
@@ -200,7 +202,9 @@ public class PBSCluster implements Clust
// Not a good way, but we dont have any choice
if (session instanceof ExtendedSession) {
- ((ExtendedSession) session).setAuthenticationInfo((GSIAuthenticationInfo)authenticationInfo);
+ if (authenticationInfo instanceof GSIAuthenticationInfo) {
+ ((ExtendedSession) session).setAuthenticationInfo((GSIAuthenticationInfo) authenticationInfo);
+ }
}
try {
@@ -281,7 +285,7 @@ public class PBSCluster implements Clust
" connecting user name - "
+ serverInfo.getUserName(), e);
} finally {
- if(tempPBSFile != null){
+ if (tempPBSFile != null) {
tempPBSFile.delete();
}
}
Modified: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java?rev=1529931&r1=1529930&r2=1529931&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java (original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/util/SSHUtils.java Mon Oct 7 15:05:40 2013
@@ -21,10 +21,13 @@
package org.apache.airavata.gsi.ssh.util;
import com.jcraft.jsch.*;
+import com.sun.tools.javac.util.Paths;
+import org.apache.airavata.gsi.ssh.api.CommandOutput;
import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
import org.apache.airavata.gsi.ssh.api.SSHApiException;
import org.apache.airavata.gsi.ssh.api.ServerInfo;
import org.apache.airavata.gsi.ssh.config.ConfigReader;
+import org.apache.airavata.gsi.ssh.impl.SystemCommandOutput;
import org.apache.airavata.gsi.ssh.jsch.ExtendedJSch;
import org.slf4j.*;
@@ -50,6 +53,7 @@ public class SSHUtils {
/**
* We need to pass certificateLocation when we use SCPTo method standalone
+ *
* @param serverInfo
* @param authenticationInfo
* @param certificateLocation
@@ -64,6 +68,7 @@ public class SSHUtils {
/**
* This can be used when use SCPTo method within SSHAPi because SSHApiFactory already set the system property certificateLocation
+ *
* @param serverInfo
* @param authenticationInfo
* @param configReader
@@ -74,6 +79,7 @@ public class SSHUtils {
this.authenticationInfo = authenticationInfo;
this.configReader = configReader;
}
+
/**
* This method will scp the lFile to the rFile location
*
@@ -82,8 +88,9 @@ public class SSHUtils {
* @throws IOException
* @throws JSchException
* @throws org.apache.airavata.gsi.ssh.api.SSHApiException
+ *
*/
- public Session scpTo(String rFile, String lFile) throws IOException, JSchException, SSHApiException {
+ public String scpTo(String rFile, String lFile) throws IOException, JSchException, SSHApiException {
FileInputStream fis = null;
String prefix = null;
if (new File(lFile).isDirectory()) {
@@ -189,9 +196,12 @@ public class SSHUtils {
channel.disconnect();
session.disconnect();
- return session;
+ int i = lFile.lastIndexOf("\\");
+ String substring = lFile.substring(i + 1);
+ return rFile + File.separator + substring;
}
- public static Session scpTo(String rFile, String lFile,Session session) throws IOException, JSchException, SSHApiException {
+
+ public static String scpTo(String rFile, String lFile, Session session) throws IOException, JSchException, SSHApiException {
FileInputStream fis = null;
String prefix = null;
if (new File(lFile).isDirectory()) {
@@ -263,8 +273,45 @@ public class SSHUtils {
out.close();
channel.disconnect();
+ int i = lFile.lastIndexOf("\\");
+ String substring = lFile.substring(i + 1);
+ return rFile + File.separator + substring;
+ }
+
+ public static Session makeDirectory(String path, Session session) throws IOException, JSchException, SSHApiException {
+
+ // exec 'scp -t rfile' remotely
+ String command = "mkdir " + path;
+ Channel channel = session.openChannel("exec");
+ CommandOutput commandOutput = new SystemCommandOutput();
+ ((ChannelExec) channel).setCommand(command);
+
+ // get I/O streams for remote scp
+ OutputStream out = channel.getOutputStream();
+ InputStream in = channel.getInputStream();
+ ((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 - " + session.getHost() + ":" + session.getPort() +
+ " connecting user name - "
+ + session.getUserName(), e);
+ }
+
+ commandOutput.onOutput(channel);
+
+ channel.disconnect();
+ session.disconnect();
+
+ channel.disconnect();
return session;
}
+
static int checkAck(InputStream in) throws IOException {
int b = in.read();
if (b == 0) return b;
Modified: airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt?rev=1529931&r1=1529930&r2=1529931&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt (original)
+++ airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt Mon Oct 7 15:05:40 2013
@@ -11,15 +11,31 @@
#! /bin/sh
# PBS batch job script built by Globus job manager
#
+ <xsl:if test="shellName != @xsl:nil">
##PBS -S <xsl:value-of select="ns:shellName"/>
+ </xsl:if>
+ <xsl:if test="queueName != @xsl:nil">
#PBS -q <xsl:value-of select="ns:queueName"/>
+ </xsl:if>
+ <xsl:if test="mailOptions != @xsl:nil">
#PBS -m <xsl:value-of select="ns:mailOptions"/>
+ </xsl:if>
+<xsl:if test="acountString != @xsl:nil">
#PBS -A <xsl:value-of select="ns:acountString"/>
+ </xsl:if>
+ <xsl:if test="maxWallTime != @xsl:nil">
#PBS -l walltime=<xsl:value-of select="ns:maxWallTime"/>
+ </xsl:if>
+ <xsl:if test="standardOutFile != @xsl:nil">
#PBS -o <xsl:value-of select="ns:standardOutFile"/>
+ </xsl:if>
+ <xsl:if test="standardOutFile != @xsl:nil">
#PBS -e <xsl:value-of select="ns:standardErrorFile"/>
+ </xsl:if>
+ <xsl:if test="(nodes != @xsl:nil) and (processesPerNode != @xsl:nil)">
#PBS -l nodes=<xsl:value-of select="ns:nodes"/>:ppn=<xsl:value-of select="ns:processesPerNode"/>
<xsl:text>
</xsl:text>
+ </xsl:if>
<xsl:for-each select="ns:exports/ns:name">
<xsl:value-of select="."/>=<xsl:value-of select="./@value"/><xsl:text>
</xsl:text>
export<xsl:text> </xsl:text><xsl:value-of select="."/>