Repository: airavata Updated Branches: refs/heads/master 2835d09ef -> 13c2e79e4
http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/util/SSHUtils.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/util/SSHUtils.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/util/SSHUtils.java deleted file mode 100644 index 35f6a41..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/util/SSHUtils.java +++ /dev/null @@ -1,757 +0,0 @@ -/* - * - * 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.util; - -import com.jcraft.jsch.*; - -import org.apache.airavata.gfac.ssh.api.authentication.GSIAuthenticationInfo; -import org.apache.airavata.gfac.ssh.api.SSHApiException; -import org.apache.airavata.gfac.ssh.api.ServerInfo; -import org.apache.airavata.gfac.ssh.config.ConfigReader; -import org.apache.airavata.gfac.ssh.impl.StandardOutReader; -import org.slf4j.*; - -import java.io.*; -import java.util.Arrays; -import java.util.List; - -/** - * This class is going to be useful to SCP a file to a remote grid machine using my proxy credentials - */ -public class SSHUtils { - private static final org.slf4j.Logger log = LoggerFactory.getLogger(SSHUtils.class); - - static { - JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gfac.ssh.GSSContextX509"); - JSch.setConfig("userauth.gssapi-with-mic", "com.jcraft.jsch.UserAuthGSSAPIWithMICGSSCredentials"); - - } - - private ServerInfo serverInfo; - - private GSIAuthenticationInfo authenticationInfo; - - private ConfigReader configReader; - - /** - * We need to pass certificateLocation when we use SCPTo method standalone - * - * @param serverInfo - * @param authenticationInfo - * @param certificateLocation - * @param configReader - */ - public SSHUtils(ServerInfo serverInfo, GSIAuthenticationInfo authenticationInfo, String certificateLocation, ConfigReader configReader) { - System.setProperty("X509_CERT_DIR", certificateLocation); - this.serverInfo = serverInfo; - this.authenticationInfo = authenticationInfo; - this.configReader = configReader; - } - - /** - * This can be used when use SCPTo method within SSHAPi because SSHApiFactory already set the system property certificateLocation - * - * @param serverInfo - * @param authenticationInfo - * @param configReader - */ - public SSHUtils(ServerInfo serverInfo, GSIAuthenticationInfo authenticationInfo - , ConfigReader configReader) { - this.serverInfo = serverInfo; - this.authenticationInfo = authenticationInfo; - this.configReader = configReader; - } - - /** - * This method will scp the lFile to the rFile location - * - * @param rFile remote file Path to use in scp - * @param lFile local file path to use in scp - * @throws IOException - * @throws JSchException - * @throws org.apache.airavata.gfac.ssh.api.SSHApiException - * - */ - public void scpTo(String rFile, String lFile) throws IOException, JSchException, SSHApiException { - FileInputStream fis = null; - String prefix = null; - if (new File(lFile).isDirectory()) { - prefix = lFile + File.separator; - } - JSch jsch = new JSch(); - - log.debug("Connecting to server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " with user name - " - + serverInfo.getUserName()); - - Session session = null; - - 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 = this.configReader.getProperties(); - session.setConfig(config); - - // Not a good way, but we dont have any choice - if (session instanceof ExtendedSession) { - ((ExtendedSession) session).setAuthenticationInfo(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); - } - - boolean ptimestamp = true; - - // exec 'scp -t rfile' remotely - String command = "scp " + (ptimestamp ? "-p" : "") + " -t " + rFile; - Channel channel = session.openChannel("exec"); - - StandardOutReader stdOutReader = new StandardOutReader(); - ((ChannelExec) channel).setErrStream(stdOutReader.getStandardError()); - ((ChannelExec) channel).setCommand(command); - - // get I/O streams for remote scp - OutputStream out = channel.getOutputStream(); - InputStream in = channel.getInputStream(); - - channel.connect(); - - if (checkAck(in) != 0) { - String error = "Error Reading input Stream"; - log.error(error); - throw new SSHApiException(error); - } - - File _lfile = new File(lFile); - - if (ptimestamp) { - command = "T" + (_lfile.lastModified() / 1000) + " 0"; - // The access time should be sent here, - // but it is not accessible with JavaAPI ;-< - command += (" " + (_lfile.lastModified() / 1000) + " 0\n"); - out.write(command.getBytes()); - out.flush(); - if (checkAck(in) != 0) { - String error = "Error Reading input Stream"; - log.error(error); - throw new SSHApiException(error); - } - } - - // send "C0644 filesize filename", where filename should not include '/' - long filesize = _lfile.length(); - command = "C0644 " + filesize + " "; - if (lFile.lastIndexOf('/') > 0) { - command += lFile.substring(lFile.lastIndexOf('/') + 1); - } else { - command += lFile; - } - command += "\n"; - out.write(command.getBytes()); - out.flush(); - if (checkAck(in) != 0) { - String error = "Error Reading input Stream"; - log.error(error); - throw new SSHApiException(error); - } - - // send a content of lFile - fis = new FileInputStream(lFile); - byte[] buf = new byte[1024]; - while (true) { - int len = fis.read(buf, 0, buf.length); - if (len <= 0) break; - out.write(buf, 0, len); //out.flush(); - } - fis.close(); - fis = null; - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - if (checkAck(in) != 0) { - String error = "Error Reading input Stream"; - log.error(error); - throw new SSHApiException(error); - } - out.close(); - - stdOutReader.onOutput(channel); - - - if (stdOutReader.getStdErrorString().contains("scp:")) { - throw new SSHApiException(stdOutReader.getStdErrorString()); - } - channel.disconnect(); - } - - /** - * This will copy a local file to a remote location - * - * @param remoteFile remote location you want to transfer the file, this cannot be a directory, if user pass - * a dirctory we do copy it to that directory but we simply return the directory name - * todo handle the directory name as input and return the proper final output file name - * @param localFile Local file to transfer, this can be a directory - * @param session - * @return returns the final remote file path, so that users can use the new file location - * @throws IOException - * @throws JSchException - * @throws SSHApiException - */ - public static String scpTo(String remoteFile, String localFile, Session session) throws IOException, JSchException, SSHApiException { - FileInputStream fis = null; - String prefix = null; - if (new File(localFile).isDirectory()) { - prefix = localFile + File.separator; - } - boolean ptimestamp = true; - - // exec 'scp -t rfile' remotely - String command = "scp " + (ptimestamp ? "-p" : "") + " -t " + remoteFile; - Channel channel = session.openChannel("exec"); - - StandardOutReader stdOutReader = new StandardOutReader(); - ((ChannelExec) channel).setErrStream(stdOutReader.getStandardError()); - ((ChannelExec) channel).setCommand(command); - - // get I/O streams for remote scp - OutputStream out = channel.getOutputStream(); - InputStream in = channel.getInputStream(); - - channel.connect(); - - if (checkAck(in) != 0) { - String error = "Error Reading input Stream"; - log.error(error); - throw new SSHApiException(error); - } - - File _lfile = new File(localFile); - - if (ptimestamp) { - command = "T" + (_lfile.lastModified() / 1000) + " 0"; - // The access time should be sent here, - // but it is not accessible with JavaAPI ;-< - command += (" " + (_lfile.lastModified() / 1000) + " 0\n"); - out.write(command.getBytes()); - out.flush(); - if (checkAck(in) != 0) { - String error = "Error Reading input Stream"; - log.error(error); - throw new SSHApiException(error); - } - } - - // send "C0644 filesize filename", where filename should not include '/' - long filesize = _lfile.length(); - command = "C0644 " + filesize + " "; - if (localFile.lastIndexOf('/') > 0) { - command += localFile.substring(localFile.lastIndexOf('/') + 1); - } else { - command += localFile; - } - command += "\n"; - out.write(command.getBytes()); - out.flush(); - if (checkAck(in) != 0) { - String error = "Error Reading input Stream"; - log.error(error); - throw new SSHApiException(error); - } - - // send a content of lFile - fis = new FileInputStream(localFile); - byte[] buf = new byte[1024]; - while (true) { - int len = fis.read(buf, 0, buf.length); - if (len <= 0) break; - out.write(buf, 0, len); //out.flush(); - } - fis.close(); - fis = null; - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - if (checkAck(in) != 0) { - String error = "Error Reading input Stream"; - log.error(error); - throw new SSHApiException(error); - } - out.close(); - stdOutReader.onOutput(channel); - - - channel.disconnect(); - if (stdOutReader.getStdErrorString().contains("scp:")) { - throw new SSHApiException(stdOutReader.getStdErrorString()); - } - //since remote file is always a file we just return the file - return remoteFile; - } - - /** - * This method will copy a remote file to a local directory - * - * @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 - * @param session - * @return returns the final local file path of the new file came from the remote resource - */ - public static void scpFrom(String remoteFile, String localFile, Session session) throws IOException, JSchException, SSHApiException { - FileOutputStream fos = null; - try { - String prefix = null; - if (new File(localFile).isDirectory()) { - prefix = localFile + File.separator; - } - - // exec 'scp -f remotefile' remotely - String command = "scp -f " + remoteFile; - Channel channel = session.openChannel("exec"); - ((ChannelExec) channel).setCommand(command); - - StandardOutReader stdOutReader = new StandardOutReader(); - ((ChannelExec) channel).setErrStream(stdOutReader.getStandardError()); - // get I/O streams for remote scp - OutputStream out = channel.getOutputStream(); - InputStream in = channel.getInputStream(); - - channel.connect(); - - byte[] buf = new byte[1024]; - - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - - while (true) { - int c = checkAck(in); - if (c != 'C') { - break; - } - - // read '0644 ' - in.read(buf, 0, 5); - - long filesize = 0L; - while (true) { - if (in.read(buf, 0, 1) < 0) { - // error - break; - } - if (buf[0] == ' ') break; - filesize = filesize * 10L + (long) (buf[0] - '0'); - } - - String file = null; - for (int i = 0; ; i++) { - in.read(buf, i, 1); - if (buf[i] == (byte) 0x0a) { - file = new String(buf, 0, i); - break; - } - } - - //System.out.println("filesize="+filesize+", file="+file); - - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - - // read a content of lfile - fos = new FileOutputStream(prefix == null ? localFile : prefix + file); - int foo; - while (true) { - if (buf.length < filesize) foo = buf.length; - else foo = (int) filesize; - foo = in.read(buf, 0, foo); - if (foo < 0) { - // error - break; - } - fos.write(buf, 0, foo); - filesize -= foo; - if (filesize == 0L) break; - } - fos.close(); - fos = null; - - if (checkAck(in) != 0) { - String error = "Error transfering the file content"; - log.error(error); - throw new SSHApiException(error); - } - - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - } - stdOutReader.onOutput(channel); - if (stdOutReader.getStdErrorString().contains("scp:")) { - throw new SSHApiException(stdOutReader.getStdErrorString()); - } - - } catch (Exception e) { - log.error(e.getMessage(), e); - } finally { - try { - if (fos != null) fos.close(); - } catch (Exception ee) { - } - } - } - - /** - * This method will copy a remote file to a local directory - * - * @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 - */ - public void scpFrom(String remoteFile, String localFile) throws SSHApiException { - JSch jsch = new JSch(); - - log.debug("Connecting to server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " with user name - " - + serverInfo.getUserName()); - - Session session = null; - - 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 = this.configReader.getProperties(); - session.setConfig(config); - - // Not a good way, but we dont have any choice - if (session instanceof ExtendedSession) { - ((ExtendedSession) session).setAuthenticationInfo(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); - } - - FileOutputStream fos = null; - try { - String prefix = null; - if (new File(localFile).isDirectory()) { - prefix = localFile + File.separator; - } - - // exec 'scp -f remotefile' remotely - StandardOutReader stdOutReader = new StandardOutReader(); - String command = "scp -f " + remoteFile; - Channel channel = session.openChannel("exec"); - ((ChannelExec) channel).setCommand(command); - ((ChannelExec) channel).setErrStream(stdOutReader.getStandardError()); - // get I/O streams for remote scp - OutputStream out = channel.getOutputStream(); - InputStream in = channel.getInputStream(); - - channel.connect(); - - byte[] buf = new byte[1024]; - - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - - while (true) { - int c = checkAck(in); - if (c != 'C') { - break; - } - - // read '0644 ' - in.read(buf, 0, 5); - - long filesize = 0L; - while (true) { - if (in.read(buf, 0, 1) < 0) { - // error - break; - } - if (buf[0] == ' ') break; - filesize = filesize * 10L + (long) (buf[0] - '0'); - } - - String file = null; - for (int i = 0; ; i++) { - in.read(buf, i, 1); - if (buf[i] == (byte) 0x0a) { - file = new String(buf, 0, i); - break; - } - } - - //System.out.println("filesize="+filesize+", file="+file); - - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - - // read a content of lfile - fos = new FileOutputStream(prefix == null ? localFile : prefix + file); - int foo; - while (true) { - if (buf.length < filesize) foo = buf.length; - else foo = (int) filesize; - foo = in.read(buf, 0, foo); - if (foo < 0) { - // error - break; - } - fos.write(buf, 0, foo); - filesize -= foo; - if (filesize == 0L) break; - } - fos.close(); - fos = null; - - if (checkAck(in) != 0) { - String error = "Error transfering the file content"; - log.error(error); - throw new SSHApiException(error); - } - - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - } - -// session.disconnect(); - - stdOutReader.onOutput(channel); - if (stdOutReader.getStdErrorString().contains("scp:")) { - throw new SSHApiException(stdOutReader.getStdErrorString()); - } - } catch (Exception e) { - log.error(e.getMessage(), e); - } finally { - try { - if (fos != null) fos.close(); - } catch (Exception ee) { - } - } - } - - /** - * This method will copy a remote file to a local directory - * - * @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 - * @param session - * @return returns the final local file path of the new file came from the remote resource - */ - public static void scpThirdParty(String remoteFileSource, String remoteFileTarget, Session session) throws IOException, JSchException, SSHApiException { - FileOutputStream fos = null; - try { - String prefix = null; - - // exec 'scp -f remotefile' remotely - String command = "scp -3 " + remoteFileSource + " " + remoteFileTarget; - Channel channel = session.openChannel("exec"); - ((ChannelExec) channel).setCommand(command); - - StandardOutReader stdOutReader = new StandardOutReader(); - ((ChannelExec) channel).setErrStream(stdOutReader.getStandardError()); - // get I/O streams for remote scp - OutputStream out = channel.getOutputStream(); - InputStream in = channel.getInputStream(); - - channel.connect(); - - byte[] buf = new byte[1024]; - - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - - while (true) { - int c = checkAck(in); - if (c != 'C') { - break; - } - - // read '0644 ' - in.read(buf, 0, 5); - - long filesize = 0L; - while (true) { - if (in.read(buf, 0, 1) < 0) { - // error - break; - } - if (buf[0] == ' ') break; - filesize = filesize * 10L + (long) (buf[0] - '0'); - } - int foo; - while (true) { - if (buf.length < filesize) foo = buf.length; - else foo = (int) filesize; - - int len = in.read(buf, 0, foo); - if (len <= 0) break; - out.write(buf, 0, len); - } - // send '\0' - buf[0] = 0; - out.write(buf, 0, 1); - out.flush(); - if (checkAck(in) != 0) { - String error = "Error transfering the file content"; - log.error(error); - throw new SSHApiException(error); - } - - } - out.close(); - - stdOutReader.onOutput(channel); - if (stdOutReader.getStdErrorString().contains("scp:")) { - throw new SSHApiException(stdOutReader.getStdErrorString()); - } - - } catch (Exception e) { - log.error(e.getMessage(), e); - } finally { - try { - if (fos != null) fos.close(); - } catch (Exception ee) { - } - } - } - - public static void makeDirectory(String path, Session session) throws IOException, JSchException, SSHApiException { - - // exec 'scp -t rfile' remotely - String command = "mkdir -p " + path; - Channel channel = session.openChannel("exec"); - StandardOutReader stdOutReader = new StandardOutReader(); - - ((ChannelExec) channel).setCommand(command); - - - ((ChannelExec) channel).setErrStream(stdOutReader.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); - } - stdOutReader.onOutput(channel); - if (stdOutReader.getStdErrorString().contains("mkdir:")) { - throw new SSHApiException(stdOutReader.getStdErrorString()); - } - - channel.disconnect(); - } - - public static List<String> listDirectory(String path, Session session) throws IOException, JSchException, SSHApiException { - - // exec 'scp -t rfile' remotely - String command = "ls " + path; - Channel channel = session.openChannel("exec"); - StandardOutReader stdOutReader = new StandardOutReader(); - - ((ChannelExec) channel).setCommand(command); - - - ((ChannelExec) channel).setErrStream(stdOutReader.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); - } - stdOutReader.onOutput(channel); - stdOutReader.getStdOutputString(); - if (stdOutReader.getStdErrorString().contains("ls:")) { - throw new SSHApiException(stdOutReader.getStdErrorString()); - } - channel.disconnect(); - return Arrays.asList(stdOutReader.getStdOutputString().split("\n")); - } - - static int checkAck(InputStream in) throws IOException { - int b = in.read(); - if (b == 0) return b; - if (b == -1) return b; - - if (b == 1 || b == 2) { - StringBuffer sb = new StringBuffer(); - int c; - do { - c = in.read(); - sb.append((char) c); - } - while (c != '\n'); - if (b == 1) { // error - System.out.print(sb.toString()); - } - if (b == 2) { // fatal error - System.out.print(sb.toString()); - } - } - return b; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/resources/LSFTemplate.xslt ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/resources/LSFTemplate.xslt b/tools/gsissh/src/main/resources/LSFTemplate.xslt deleted file mode 100644 index c548d8e..0000000 --- a/tools/gsissh/src/main/resources/LSFTemplate.xslt +++ /dev/null @@ -1,93 +0,0 @@ -<!--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:param name="quote">"</xsl:param> -#! /bin/bash -# LSF batch job submission script generated by Apache Airavata -# - <xsl:choose> - <xsl:when test="ns:shellName"> -#BSUB -L <xsl:value-of select="ns:shellName"/> - </xsl:when></xsl:choose> - <xsl:choose> - <xsl:when test="ns:queueName"> -#BSUB -q <xsl:value-of select="ns:queueName"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:nodes"> -#BSUB -n <xsl:value-of select="ns:nodes"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:mailAddress"> -#BSUB -u <xsl:value-of select="ns:mailAddress"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:jobName"> -#BSUB -J <xsl:value-of select="ns:jobName"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:acountString"> -#BSUB -P <xsl:value-of select="ns:acountString"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:maxWallTime"> -#BSUB -W <xsl:value-of select="ns:maxWallTime"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:standardOutFile"> -#BSUB -o "<xsl:value-of select="ns:standardOutFile"/>" - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:standardOutFile"> -#BSUB -e "<xsl:value-of select="ns:standardErrorFile"/>" - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:chassisName"> -#BSUB -m c<xsl:value-of select="ns:chassisName"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:usedMem"> -#BSUB -R rusage[mem=<xsl:value-of select="ns:usedMem"/>] - </xsl:when> - </xsl:choose> - - <xsl:text>
</xsl:text> - - <xsl:text>
</xsl:text> - <xsl:for-each select="ns:moduleLoadCommands/ns:command"> - <xsl:text>
</xsl:text> - <xsl:value-of select="."/><xsl:text> </xsl:text> - </xsl:for-each> - <xsl:text>
</xsl:text> -cd <xsl:text> </xsl:text><xsl:value-of select="ns:workingDirectory"/><xsl:text>
</xsl:text> - <xsl:for-each select="ns:preJobCommands/ns:command"> - <xsl:value-of select="."/><xsl:text> </xsl:text> - <xsl:text>
</xsl:text> - </xsl:for-each> - <xsl:text>
</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:text>
</xsl:text> - </xsl:template> - -</xsl:stylesheet> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/resources/PBSTemplate.xslt ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/resources/PBSTemplate.xslt b/tools/gsissh/src/main/resources/PBSTemplate.xslt deleted file mode 100644 index 73c5eb6..0000000 --- a/tools/gsissh/src/main/resources/PBSTemplate.xslt +++ /dev/null @@ -1,82 +0,0 @@ -<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file - distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under - the Apache License, Version 2.0 (theà "License"); you may not use this file except in compliance with the License. You may - obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to - in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF - ANY ~ KIND, either express or implied. See the License for the specific language governing permissions and limitations under - the License. --> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://airavata.apache.org/gsi/ssh/2012/12"> -<xsl:output method="text" /> -<xsl:template match="/ns:JobDescriptor"> -#! /bin/sh -# <xsl:choose> - <xsl:when test="ns:shellName"> -##PBS -S <xsl:value-of select="ns:shellName"/> - </xsl:when></xsl:choose> - <xsl:choose> - <xsl:when test="ns:queueName"> -#PBS -q <xsl:value-of select="ns:queueName"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:mailOptions"> -#PBS -m <xsl:value-of select="ns:mailOptions"/> - </xsl:when> - </xsl:choose> - <xsl:choose> -<xsl:when test="ns:acountString"> -#PBS -A <xsl:value-of select="ns:acountString"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:maxWallTime"> -#PBS -l walltime=<xsl:value-of select="ns:maxWallTime"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:jobName"> -#PBS -N <xsl:value-of select="ns:jobName"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:standardOutFile"> -#PBS -o <xsl:value-of select="ns:standardOutFile"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:standardOutFile"> -#PBS -e <xsl:value-of select="ns:standardErrorFile"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:usedMem"> -#PBS -l mem=<xsl:value-of select="ns:usedMem"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="(ns:nodes) and (ns:processesPerNode)"> -#PBS -l nodes=<xsl:value-of select="ns:nodes"/>:ppn=<xsl:value-of select="ns:processesPerNode"/> -<xsl:text>
</xsl:text> - </xsl:when> - </xsl:choose> -<xsl:for-each select="ns:exports/ns:name"> -<xsl:value-of select="."/>=<xsl:value-of select="./@value"/><xsl:text>
</xsl:text> -export<xsl:text> </xsl:text><xsl:value-of select="."/> -<xsl:text>
</xsl:text> -</xsl:for-each> -<xsl:for-each select="ns:preJobCommands/ns:command"> - <xsl:value-of select="."/><xsl:text> </xsl:text> - </xsl:for-each> -cd <xsl:text> </xsl:text><xsl:value-of select="ns:workingDirectory"/><xsl:text>
</xsl:text> - <xsl:choose><xsl:when test="ns:jobSubmitterCommand"> -<xsl:value-of select="ns:jobSubmitterCommand"/><xsl:text> </xsl:text></xsl:when></xsl:choose><xsl:value-of select="ns:executablePath"/><xsl:text> </xsl:text> -<xsl:for-each select="ns:inputs/ns:input"> - <xsl:value-of select="."/><xsl:text> </xsl:text> - </xsl:for-each> -<xsl:for-each select="ns:postJobCommands/ns:command"> - <xsl:value-of select="."/><xsl:text> </xsl:text> -</xsl:for-each> - -</xsl:template> - -</xsl:stylesheet> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/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 deleted file mode 100644 index 4a62722..0000000 --- a/tools/gsissh/src/main/resources/SLURMTemplate.xslt +++ /dev/null @@ -1,78 +0,0 @@ -<!--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:cpuCount"> -#SBATCH -n <xsl:value-of select="ns:cpuCount"/> - </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> - <xsl:for-each select="ns:preJobCommands/ns:command"> - <xsl:text>
</xsl:text> - <xsl:value-of select="."/><xsl:text> </xsl:text> - </xsl:for-each> -cd <xsl:text> </xsl:text><xsl:value-of select="ns:workingDirectory"/><xsl:text>
</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/13c2e79e/tools/gsissh/src/main/resources/UGETemplate.xslt ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/resources/UGETemplate.xslt b/tools/gsissh/src/main/resources/UGETemplate.xslt deleted file mode 100644 index 5b57265..0000000 --- a/tools/gsissh/src/main/resources/UGETemplate.xslt +++ /dev/null @@ -1,74 +0,0 @@ -<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file - distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under - the Apache License, Version 2.0 (theà "License"); you may not use this file except in compliance with the License. You may - obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to - in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF - ANY ~ KIND, either express or implied. See the License for the specific language governing permissions and limitations under - the License. --> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://airavata.apache.org/gsi/ssh/2012/12"> -<xsl:output method="text" /> -<xsl:template match="/ns:JobDescriptor"> -#! /bin/bash -# Grid Engine batch job script built by Apache Airavata -# <xsl:choose> - <xsl:when test="ns:shellName"> -#$ -S <xsl:value-of select="ns:shellName"/> - </xsl:when></xsl:choose> -#$ -V - <xsl:choose> - <xsl:when test="ns:queueName"> -#$ -q <xsl:value-of select="ns:queueName"/> - </xsl:when> - </xsl:choose> -#$ -m beas <xsl:choose> -<xsl:when test="ns:acountString"> -#$ -A <xsl:value-of select="ns:acountString"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:maxWallTime"> -#$ -l h_rt=<xsl:value-of select="ns:maxWallTime"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:jobName"> -#$ -N <xsl:value-of select="ns:jobName"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:standardOutFile"> -#$ -o <xsl:value-of select="ns:standardOutFile"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="ns:standardOutFile"> -#$ -e <xsl:value-of select="ns:standardErrorFile"/> - </xsl:when> - </xsl:choose> - <xsl:choose> - <xsl:when test="(ns:nodes) and (ns:processesPerNode)"> -#$ -pe <xsl:value-of select="ns:processesPerNode"/>way <xsl:value-of select="12 * ns:nodes"/> -<xsl:text>
</xsl:text> - </xsl:when> - </xsl:choose> -<xsl:for-each select="ns:exports/ns:name"> -<xsl:value-of select="."/>=<xsl:value-of select="./@value"/><xsl:text>
</xsl:text> -export<xsl:text> </xsl:text><xsl:value-of select="."/> -<xsl:text>
</xsl:text> -</xsl:for-each> -<xsl:for-each select="ns:preJobCommands/ns:command"> - <xsl:value-of select="."/><xsl:text> </xsl:text> - </xsl:for-each> -cd <xsl:text> </xsl:text><xsl:value-of select="ns:workingDirectory"/><xsl:text>
</xsl:text> - <xsl:choose><xsl:when test="ns:jobSubmitterCommand"> -<xsl:value-of select="ns:jobSubmitterCommand"/><xsl:text> </xsl:text></xsl:when></xsl:choose><xsl:value-of select="ns:executablePath"/><xsl:text> </xsl:text> -<xsl:for-each select="ns:inputs/ns:input"> - <xsl:value-of select="."/><xsl:text> </xsl:text> - </xsl:for-each> -<xsl:for-each select="ns:postJobCommands/ns:command"> - <xsl:value-of select="."/><xsl:text> </xsl:text> -</xsl:for-each> - -</xsl:template> - -</xsl:stylesheet> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/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 deleted file mode 100644 index d5c5992..0000000 --- a/tools/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd +++ /dev/null @@ -1,114 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!--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. --> - -<schema targetNamespace="http://airavata.apache.org/gsi/ssh/2012/12" xmlns:gsissh="http://airavata.apache.org/gsi/ssh/2012/12" - xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> - - <element name="JobDescriptor" type="gsissh:pbsParams" /> - - <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" /> - <element name="standardErrorFile" type="xsd:string" minOccurs="0" maxOccurs="1" /> - <element name="outputDirectory" type="xsd:string" minOccurs="0" maxOccurs="1" /> - <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="cpuCount" 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"/> - <element name="exports" type="gsissh:exportProperties" minOccurs="1" maxOccurs="1"/> - <element name="status" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="afterAny" type="gsissh:afterAnyList" minOccurs="0" maxOccurs="1"/> - <element name="afterOKList" type="gsissh:afterOKList" minOccurs="0" maxOccurs="1"/> - <element name="cTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="qTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="mTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="sTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="compTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="owner" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="executeNode" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="ellapsedTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="usedCPUTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="usedMem" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="submitArgs" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="variableList" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="preJobCommands" type="gsissh:preJobCommands" minOccurs="0" maxOccurs="1"/> - <element name="moduleLoadCommands" type="gsissh:moduleLoadCommands" minOccurs="0" maxOccurs="1"/> - <element name="postJobCommands" type="gsissh:postJobCommands" minOccurs="0" maxOccurs="1"/> - <element name="jobSubmitterCommand" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="callBackIp" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="callBackPort" type="xsd:string" minOccurs="0" maxOccurs="1"/> - <element name="chassisName" type="xsd:string" minOccurs="0" maxOccurs="1"/> - </sequence> - </complexType> - - <complexType name="moduleLoadCommands"> - <sequence> - <element name="command" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> - </sequence> - </complexType> - <complexType name="preJobCommands"> - <sequence> - <element name="command" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> - </sequence> - </complexType> - - <complexType name="postJobCommands"> - <sequence> - <element name="command" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> - </sequence> - </complexType> - <complexType name="inputList"> - <sequence> - <element name="input" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> - </sequence> - </complexType> - <complexType name="afterAnyList"> - <sequence> - <element name="afterAny" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> - </sequence> - </complexType> - - <complexType name="afterOKList"> - <sequence> - <element name="afterOKList" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> - </sequence> - </complexType> - - <complexType name="exportProperties"> - <sequence> - - <element name="name" minOccurs="1" maxOccurs="unbounded"> - <complexType> - <simpleContent> - <extension base="xsd:string"> - <attribute name="value" type="xsd:string" use="required" /> - </extension> - </simpleContent> - </complexType> - </element> - - </sequence> - </complexType> -</schema> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/resources/schemas/gsissh-schemas.xsdconfig ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/resources/schemas/gsissh-schemas.xsdconfig b/tools/gsissh/src/main/resources/schemas/gsissh-schemas.xsdconfig deleted file mode 100644 index a46cadc..0000000 --- a/tools/gsissh/src/main/resources/schemas/gsissh-schemas.xsdconfig +++ /dev/null @@ -1,14 +0,0 @@ -<!--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. --> - -<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config"> - - <xb:namespace uri="http://airavata.apache.org/schemas/gsi/ssh/2012/12"> - <xb:package>org.apache.airavata.gfac.ssh</xb:package> - </xb:namespace> -</xb:config> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/config/ConfigReaderTest.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/config/ConfigReaderTest.java b/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/config/ConfigReaderTest.java deleted file mode 100644 index a90dcba..0000000 --- a/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/config/ConfigReaderTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * 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.config; - -import org.testng.Assert; -import org.testng.annotations.Test; - -public class ConfigReaderTest { - - @Test - public void testGetConfiguration() throws Exception { - - System.out.println("Test case name " + this.getClass().getName()); - ConfigReader configReader = new ConfigReader(); - Assert.assertEquals(configReader.getConfiguration("StrictHostKeyChecking"), "no"); - - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java b/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java deleted file mode 100644 index 61a7437..0000000 --- a/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * 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.impl; - -import org.apache.airavata.gfac.ssh.api.*; -import org.apache.airavata.gfac.ssh.config.ConfigReader; -import org.apache.airavata.gfac.ssh.impl.authentication.DefaultPublicKeyAuthentication; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; - -public class DefaultSSHApiTestWithMyProxyAuth { - private static final Logger log = LoggerFactory.getLogger(PBSCluster.class); - - - - public void tearDown() throws Exception { - } - - - public static void main(String[]ars) throws IOException { - String myProxyUserName = "lg11w"; - -// DefaultPasswordAuthenticationInfo authenticationInfo -// = new DefaultPasswordAuthenticationInfo(""); - byte[] privateKey = IOUtils.toByteArray(new BufferedInputStream(new FileInputStream("/Users/lginnali/.ssh/id_dsa"))); - byte[] publicKey = IOUtils.toByteArray(new BufferedInputStream(new FileInputStream("/Users/lginnali/.ssh/id_dsa.pub"))); - DefaultPublicKeyAuthentication authenticationInfo = new DefaultPublicKeyAuthentication(privateKey,publicKey,""); - - // Create command - CommandInfo commandInfo = new RawCommandInfo("source /etc/bashrc; bsub </home/lg11w/mywork/sshEchoExperiment_9d267072-ca65-4ca8-847a-cd3d130f6050/366787899.lsf"); - - // Server info - //Stampede -// ServerInfo serverInfo = new ServerInfo(myProxyUserName, "stampede.tacc.utexas.edu", 2222); - //Trestles -// ServerInfo serverInfo = new ServerInfo(myProxyUserName, "trestles.sdsc.xsede.org", 22); - - //Lonestar - ServerInfo serverInfo = new ServerInfo(myProxyUserName, "ghpcc06.umassrc.org", 22); - // Output - CommandOutput commandOutput = new SystemCommandOutput(); - - // Execute command - try { - CommandExecutor.executeCommand(commandInfo, serverInfo, authenticationInfo, commandOutput, new ConfigReader()); - } catch (SSHApiException e) { - log.error(e.getMessage(), e); - } catch (IOException e) { - log.error(e.getMessage(), e); - } - } - - - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/impl/VanilaTestWithSSHAuth.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/impl/VanilaTestWithSSHAuth.java b/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/impl/VanilaTestWithSSHAuth.java deleted file mode 100644 index 6f2840f..0000000 --- a/tools/gsissh/src/test/java/org/apache/airavata/gfac/ssh/impl/VanilaTestWithSSHAuth.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * - * 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.impl; - -import org.apache.airavata.gfac.ssh.api.*; -import org.apache.airavata.gfac.ssh.api.authentication.AuthenticationInfo; -import org.apache.airavata.gfac.ssh.api.job.JobDescriptor; -import org.apache.airavata.gfac.ssh.impl.authentication.DefaultPasswordAuthenticationInfo; -import org.apache.airavata.gfac.ssh.impl.authentication.DefaultPublicKeyFileAuthentication; -import org.apache.airavata.gfac.ssh.util.CommonUtils; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -public class VanilaTestWithSSHAuth { - - private String userName; - private String password; - private String passPhrase; - private String hostName; - private String workingDirectory; - private String privateKeyPath; - private String publicKeyPath; - private String path; - - @BeforeTest - public void setUp() throws Exception { - System.out.println("Test case name " + this.getClass().getName()); - //Trestles - this.hostName = "trestles.sdsc.xsede.org"; - this.userName = "ogce"; - this.path="/opt/torque/bin/"; - //Stampede: -// this.hostName = "stampede.tacc.xsede.org"; -// this.userName = "ogce"; -// this.path="/usr/bin"; - //Lonestar: -// this.hostName = "lonestar.tacc.utexas.edu"; -// this.userName = "us3"; -// this.path="/opt/sge6.2/bin/lx24-amd64"; - //Alamo: -// this.hostName = "alamo.uthscsa.edu"; -// this.userName = "raminder"; -// this.path="/opt/torque/bin/"; - //Bigred: -// this.hostName = "bigred2.uits.iu.edu"; -// this.userName = "cgateway"; -// this.path="/opt/torque/torque-5.0.1/bin/"; - - System.setProperty("ssh.host",hostName); - System.setProperty("ssh.username", userName); - System.setProperty("private.ssh.key", "/home/lginnali/.ssh/id_dsa"); - System.setProperty("public.ssh.key", "/home/lginnali/.ssh/id_dsa.pub"); - System.setProperty("ssh.working.directory", "/tmp"); - - this.hostName = System.getProperty("ssh.host"); - this.userName = System.getProperty("ssh.username"); - this.password = System.getProperty("ssh.password"); - this.privateKeyPath = System.getProperty("private.ssh.key"); - this.publicKeyPath = System.getProperty("public.ssh.key"); - - System.setProperty("ssh.keypass", ""); - this.passPhrase = System.getProperty("ssh.keypass"); - this.workingDirectory = System.getProperty("ssh.working.directory"); - - - if (this.userName == null - || (this.password==null && (this.publicKeyPath == null || this.privateKeyPath == null)) || this.workingDirectory == null) { - System.out.println("########### In order to test you have to either username password or private,public keys"); - System.out.println("Use -Dssh.user=xxx -Dssh.password=yyy -Dssh.private.key.passphrase=zzz " + - "-Dssh.private.key.path -Dssh.public.key.path -Dssh.working.directory "); - } - } - - - @Test - public void testSimplePBSJob() throws Exception { - - AuthenticationInfo authenticationInfo = null; - if (password != null) { - authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password); - } else { - authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath, - this.passPhrase); - } - // Server info - ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName); - Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager(path)); - - String date = new Date().toString(); - date = date.replaceAll(" ", "_"); - date = date.replaceAll(":", "_"); - - String pomFile = new File("").getAbsolutePath() + File.separator + "pom.xml"; - - workingDirectory = workingDirectory + File.separator - + date + "_" + UUID.randomUUID(); - pbsCluster.makeDirectory(workingDirectory); - Thread.sleep(1000); - pbsCluster.makeDirectory(workingDirectory + File.separator + "inputs"); - Thread.sleep(1000); - pbsCluster.makeDirectory(workingDirectory + File.separator + "outputs"); - - - // doing file transfer to the remote resource - String remoteLocation = workingDirectory + File.separator + "inputs"; - pbsCluster.scpTo(remoteLocation, pomFile); - - int i = pomFile.lastIndexOf(File.separator); - String fileName = pomFile.substring(i + 1); - // constructing the job object - JobDescriptor jobDescriptor = new JobDescriptor(); - jobDescriptor.setWorkingDirectory(workingDirectory); - jobDescriptor.setShellName("/bin/bash"); - jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB"); - jobDescriptor.setExecutablePath("/bin/echo"); - jobDescriptor.setAllEnvExport(true); - jobDescriptor.setMailOptions("n"); - jobDescriptor.setStandardOutFile(workingDirectory + File.separator + "application.out"); - jobDescriptor.setStandardErrorFile(workingDirectory + File.separator + "application.err"); - jobDescriptor.setNodes(1); - jobDescriptor.setProcessesPerNode(1); - jobDescriptor.setQueueName("normal"); - jobDescriptor.setMaxWallTime("5"); - //jobDescriptor.setJobSubmitter("aprun -n 1"); - List<String> inputs = new ArrayList<String>(); - inputs.add(remoteLocation + File.separator + fileName); - jobDescriptor.setInputValues(inputs); - //finished construction of job object - System.out.println(jobDescriptor.toXML()); - if(hostName.contains("trestles")){ - String 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 testSimpleLSFJob() throws Exception { - - AuthenticationInfo authenticationInfo = null; - if (password != null) { - authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password); - } else { - authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath, - this.passPhrase); - } - // Server info - ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName); - - - // constructing the job object - JobDescriptor jobDescriptor = new JobDescriptor(); - jobDescriptor.setWorkingDirectory(workingDirectory); - jobDescriptor.setShellName("/bin/bash"); - jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB"); - jobDescriptor.setExecutablePath("/bin/echo"); - jobDescriptor.setAllEnvExport(true); - jobDescriptor.setMailOptions("n"); - jobDescriptor.setMailAddress("[email protected]"); - jobDescriptor.setStandardOutFile(workingDirectory + File.separator + "application.out"); - jobDescriptor.setStandardErrorFile(workingDirectory + File.separator + "application.err"); - jobDescriptor.setNodes(1); - jobDescriptor.setProcessesPerNode(1); - jobDescriptor.setQueueName("long"); - jobDescriptor.setMaxWallTimeForLSF("5"); - jobDescriptor.setJobSubmitter("mpiexec"); - jobDescriptor.setModuleLoadCommands(new String[]{"module load openmpi/1.6.5"}); - jobDescriptor.setUsedMemory("1000"); - jobDescriptor.setChassisName("01"); - - //jobDescriptor.setJobSubmitter("aprun -n 1"); - List<String> inputs = new ArrayList<String>(); - jobDescriptor.setInputValues(inputs); - //finished construction of job object - System.out.println(jobDescriptor.toXML()); - Cluster pbsCluster = new PBSCluster(CommonUtils.getLSFJobManager("")); - ((PBSCluster) pbsCluster).generateJobScript(jobDescriptor); - } - - @Test - public void testSCPFromAndSCPTo() throws Exception { - - AuthenticationInfo authenticationInfo = null; - if (password != null) { - authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password); - } else { - authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath, - this.passPhrase); - } - // Server info - ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName); - Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager(path)); - new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager(path));; - - String date = new Date().toString(); - date = date.replaceAll(" ", "_"); - date = date.replaceAll(":", "_"); - - String pomFile = (new File(".")).getAbsolutePath() + File.separator + "pom.xml"; - File file = new File(pomFile); - if(!file.exists()){ - file.createNewFile(); - } - // Constructing theworking directory for demonstration and creating directories in the remote - // resource - workingDirectory = workingDirectory + File.separator - + date + "_" + UUID.randomUUID(); - pbsCluster.makeDirectory(workingDirectory); - pbsCluster.scpTo(workingDirectory, pomFile); - Thread.sleep(1000); - pbsCluster.scpFrom(workingDirectory + File.separator + "pom.xml", (new File(".")).getAbsolutePath()); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/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 deleted file mode 100644 index 3fdf76d..0000000 --- a/tools/gsissh/src/test/resources/gsissh.properties +++ /dev/null @@ -1,26 +0,0 @@ -# -# -# 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 http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/test/resources/log4j.properties b/tools/gsissh/src/test/resources/log4j.properties deleted file mode 100644 index 257802c..0000000 --- a/tools/gsissh/src/test/resources/log4j.properties +++ /dev/null @@ -1,34 +0,0 @@ -# -# 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. -# - -# Set root category priority to INFO and its only appender to CONSOLE. -log4j.rootCategory=ALL, CONSOLE,LOGFILE -log4j.rootLogger=ALL, CONSOLE, LOGFILE - - -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=./target/integration-tests.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/test/resources/sleep.pbs ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/test/resources/sleep.pbs b/tools/gsissh/src/test/resources/sleep.pbs deleted file mode 100644 index 126e045..0000000 --- a/tools/gsissh/src/test/resources/sleep.pbs +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# -# 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. -# - -#$ -S /bin/bash -#$ -V -#$ -pe 1way 32 -#$ -m n -#$ -q normal -#$ -A -#$ -l h_rt=0:60:00 -#$ -o application.stdout -#$ -e application.stderr -#PBS -N GSI_SSH_SLEEP_JOB -/bin/sleep 60 http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/test/resources/test.pbs ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/test/resources/test.pbs b/tools/gsissh/src/test/resources/test.pbs deleted file mode 100644 index d18269b..0000000 --- a/tools/gsissh/src/test/resources/test.pbs +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -# -# -# 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. -# - -#PBS -q normal -#PBS -A sds128 -#PBS -l nodes=1:ppn=1 -#PBS -l walltime=00:00:01 -#PBS -o job_output -#PBS -N GSI_SSH_JOB -#PBS -V - -/bin/date
