From 769e91e49529834da57ca8277a05cf4c4250b49b Mon Sep 17 00:00:00 2001 From: ZihengSun Date: Sat, 7 Dec 2019 04:33:56 -0500 Subject: [PATCH 1/4] update --- src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java | 2 +- .../gmu/csiss/earthcube/cyberconnector/ssh/WorkflowTool.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java index 6a2b6fa5a..9d16332ed 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java @@ -530,7 +530,7 @@ public static String executeShell(String id, String hid, String pswd, String tok if(token == null) { - token = new RandomString(12).nextString(); + token = hid; //new RandomString(12).nextString(); } diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/WorkflowTool.java b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/WorkflowTool.java index 637a30f91..f6016031d 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/WorkflowTool.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/WorkflowTool.java @@ -349,7 +349,7 @@ public static String execute(String id, String mode, String[] hosts, String[] ps if(BaseTool.isNull(token)) { - token = new RandomString(12).nextString(); //this token will be used to establish websocket session + token = task.getHistory_id(); //new RandomString(12).nextString(); //this token will be used to establish websocket session } From 9aff7ad8f861666a1b66fab037586c4b1638d594 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Wed, 18 Dec 2019 16:17:29 -0500 Subject: [PATCH 2/4] update --- WebContent/WEB-INF/lib/jtar-2.3.jar | Bin 0 -> 17178 bytes .../geoweaver/js/edu.gmu.csiss.geoweaver.js | 2 +- pom.xml | 7 +- .../cyberconnector/ssh/FileTool.java | 78 +++++++++- .../cyberconnector/ssh/ProcessTool.java | 137 ++++++++++++++++-- .../cyberconnector/ssh/SSHSession.java | 2 +- .../cyberconnector/ssh/SSHSessionImpl.java | 25 +++- .../cyberconnector/utils/BaseTool.java | 47 ++++++ 8 files changed, 279 insertions(+), 19 deletions(-) create mode 100644 WebContent/WEB-INF/lib/jtar-2.3.jar diff --git a/WebContent/WEB-INF/lib/jtar-2.3.jar b/WebContent/WEB-INF/lib/jtar-2.3.jar new file mode 100644 index 0000000000000000000000000000000000000000..454957124c15562296ce1e252a93c074729b354d GIT binary patch literal 17178 zcmb8X1z23mwl#_dcemi~?(Po3-Q8*2A-KD{1_$|L5j!Z%`kfvZBg@w32dS^a_77g9Ix1FsnVF zfwcMf^Vg3H^&ib-1?42gM3t23WW{b}$9~92)6z}DNz+nIj7`>kVVGmy+IOUpni!^$ zrWJyO*eg^`M5pd1acjwxVg^V#Wl>e2)}jC+kZ(VJ6Y&K_`ioMxVKjKy2v#X{XP8N; zJM^H3n8zR@9%ZX8K>-!;qfVAO&fGGcyi?V^Eq^-TPlaiC8 ziGdBBk+lH;5T$Bkt)+(L6MflGb^-K6DQ-;XTQD$vJu3e(8BL$i3+U*KNy#*8epXehZj~E`!{d*=Q>h|M2To zFYFCBZB!ZoHUqU3k@whJMUmAh<-;oYcWz~#n__u0MTP5F4{1mbc zt5X8${M8~ffrV~mb_pXws#(re2tRd zNsFpB05Z0ycV&ka-}g!qX{2%QTV~=`B$j#sY?yc1lmlCCHP&V{SPCFo?3PW^Qs_eL zF2Pry&makdD-jzDBB;wPv&*EqAropz6NRRQro)mKoRj2|g_c6L5s5;BuSf=kIQ%;b z@7FnWIN*@!! z2xA?F3`Wo8;o%d*8nvIfU z>MQ)CD=#!>S@qLd7k=*oVWK%p^%sJs!lPG?bcSHI;4B^*O^4mj#Yz(h`U;(&_FO^{ zd6wiofp%=_u{a3W*3FhWCO3c5B8&{^32r%`8I+7{LkBEohb#j6e#N?!-;Oq5OetHn zaN%B_9%+lN`+Z&r%P-$4CgdAguJ##7%*~im*{_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Ez#e=Ova)WOR9j84 z7(J3%y+GLgif^U%o%OyJ%@~}ymH%;l*2gI`v%l)-jqp`2gT5Ms`uGB$?yKPL-ibS( zSu3@ibpS4Ks065j?;2!h{@b;S$j|oJ`ba+7UU>YoAA-le9Y2ls=`$Sd_JT6eO<(g%^3JQD$_;0i@@_3w$D1{ z`~qAxpL|ZS-NEf8y6U2Arq~kSAc$X}{#pe7m^$(#$oVm?{3pc! z($l}Q)4u?H*#0x%Z(Q}STK;=V_9rMJ(EIxa`#;P8e 4.0.0 Geoweaver - 0.7.7 + 0.7.8 war Geoweaver ESIPLab incubator project @@ -54,6 +54,11 @@ 4.12 test + + org.kamranzafar + jtar + 2.3 + aopalliance aopalliance diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/FileTool.java b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/FileTool.java index f8f134ee4..27a78938e 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/FileTool.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/FileTool.java @@ -15,6 +15,7 @@ import net.schmizz.sshj.sftp.RemoteResourceInfo; import net.schmizz.sshj.sftp.SFTPClient; import net.schmizz.sshj.xfer.FilePermission; +import net.schmizz.sshj.xfer.scp.SCPFileTransfer; public class FileTool { @@ -24,6 +25,79 @@ public class FileTool { static Map token2ftpclient = new HashMap(); + /** + * Upload a file from local to a specific location on a remote host + * @param hid + * @param passwd + * @param localPath + * @param remoteLoc + * @return + */ + public static String scp_upload(String hid, String passwd, String localPath, String remoteLoc, boolean removelocal) { + + String resp = null; + + SSHSession session = new SSHSessionImpl(); + + try { + + //get host ip, port, user name and password + +// String[] hostdetails = HostTool.getHostDetailsById(hid); + + //establish SSH session and generate a token for it + + session.login(hid, passwd, null, false); + + File localfile = new File(localPath); + + String filename = localfile.getName(); + + String fileloc = remoteLoc + "/" + filename; //upload file to temporary folder + + log.info("upload " + localPath + " to " + remoteLoc); + +// session.getSsh().newSCPFileTransfer().download(file_path, fileloc); + + session.getSsh().newSCPFileTransfer().upload(localPath, remoteLoc); + + //remove the local temporal files + + if(removelocal) localfile.delete(); + + session.getSsh().close(); + +// session.getSSHJSession().newSCPFileTransfer().download("test_file", new FileSystemFile("/tmp/")); + +// session.runBash(code, id, false); + + String file_url = null; + + resp = "{\"filename\": \"" + fileloc + "\", \"ret\": \"success\"}"; + + } catch (Exception e) { + + e.printStackTrace(); + + throw new RuntimeException(e.getLocalizedMessage()); + + } finally { + + + + } + + return resp; + + } + + /** + * Upload a file from local to the home directory of remote host + * @param hid + * @param passwd + * @param localPath + * @return + */ public static String scp_upload(String hid, String passwd, String localPath) { String resp = null; @@ -50,7 +124,9 @@ public static String scp_upload(String hid, String passwd, String localPath) { // session.getSsh().newSCPFileTransfer().download(file_path, fileloc); - session.getSsh().newSCPFileTransfer().upload(localPath, fileloc); + SCPFileTransfer transfer = session.getSsh().newSCPFileTransfer(); + + transfer.upload(localPath, fileloc); //remove the local temporal files diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java index 01dc4239a..e260b5bce 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java @@ -1,7 +1,10 @@ package edu.gmu.csiss.earthcube.cyberconnector.ssh; +import java.io.File; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.StringUtils; @@ -367,6 +370,39 @@ public static String del(String id) { } + /** + * Get process name by id + * @param pid + * @return + */ + public static String getNameById(String pid) { + + StringBuffer sql = new StringBuffer("select name from process_type where id = '").append(pid).append("';"); + + ResultSet rs = DataBaseOperation.query(sql.toString()); + + String name = null; + + try { + + if(rs.next()) { + + name = rs.getString("name"); + + } + + DataBaseOperation.closeConnection(); + + } catch (SQLException e) { + + e.printStackTrace(); + + } + + return name; + + } + /** * Get code by Id * @param pid @@ -374,7 +410,7 @@ public static String del(String id) { */ public static String getCodeById(String pid) { - StringBuffer sql = new StringBuffer("select code from process_type where id = '").append(pid).append("';"); + StringBuffer sql = new StringBuffer("select name,code from process_type where id = '").append(pid).append("';"); ResultSet rs = DataBaseOperation.query(sql.toString()); @@ -732,12 +768,82 @@ public static String executeBuiltInProcess(String id, String hid, String pswd, S } + /** + * Package all python files into one zip file + */ + public static String packageAllPython(String hid) { + + StringBuffer sql = new StringBuffer("select name,code from process_type where description = 'python';"); + + logger.info(sql.toString()); + + ResultSet rs = DataBaseOperation.query(sql.toString()); + + String resp = null, code = null, name = null; + + try { + + String folderpath = BaseTool.getCyberConnectorRootPath() + SysDir.temp_file_path + "/" + hid + "/"; + + resp = BaseTool.getCyberConnectorRootPath() + SysDir.temp_file_path + "/" + hid + ".tar"; + + new File(folderpath).mkdirs(); //make a temporary folder + + List files = new ArrayList(); + + while(rs.next()) { + + code = rs.getString("code"); + + name = rs.getString("name"); + + String filepath = folderpath; + + if(name.endsWith(".py")) { + + filepath += name; + + }else{ + + filepath += name + ".py"; + + } + + logger.info(filepath); + + BaseTool.writeString2File(code, filepath); + + files.add(filepath); + + } + + if(files.size()==0) { + + throw new RuntimeException("No python is found in the database"); + + } + //zip the files into a tar file + BaseTool.tar(files, resp); + + DataBaseOperation.closeConnection(); + + } catch (SQLException e) { + + e.printStackTrace(); + + } + + return resp; + + } + /** * Execute Python process * @param id * @param hid * @param pswd * @param token + * for security reasons * @param isjoin * @return */ @@ -748,11 +854,30 @@ public static String executePythonProcess(String id, String hid, String pswd, try { + if(token == null) { + + token = new RandomString(12).nextString(); + + } + + //package all the python files into a tar + String packagefile = ProcessTool.packageAllPython(token); + + if(basedir!=null) { + + FileTool.scp_upload(hid, pswd, packagefile, basedir, true); + + }else { + + FileTool.scp_upload(hid, pswd, packagefile); + + } + //get code of the process String code = getCodeById(id); - logger.info(code); +// logger.info(code); //get host ip, port, user name and password @@ -760,19 +885,13 @@ public static String executePythonProcess(String id, String hid, String pswd, //establish SSH session and generate a token for it - if(token == null) { - - token = new RandomString(12).nextString(); - - } - SSHSession session = new SSHSessionImpl(); session.login(hid, pswd, token, false); GeoweaverController.sshSessionManager.sessionsByToken.put(token, session); - session.runPython(code, id, isjoin, bin, pyenv, basedir); + session.runPython(code, id, isjoin, bin, pyenv, basedir, token); String historyid = session.getHistory_id(); diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSession.java b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSession.java index 937ffbc3e..dafa9e745 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSession.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSession.java @@ -77,7 +77,7 @@ public interface SSHSession { public void runJupyter(String script, String processid, boolean isjoin, String bin, String env, String basedir); - public void runPython(String script, String processid, boolean isjoin, String bin, String pyenv, String basedir); + public void runPython(String script, String processid, boolean isjoin, String bin, String pyenv, String basedir, String token); public void runMultipleBashes(String[] script, String processid); diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSessionImpl.java b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSessionImpl.java index 9a25fc0a5..de882bd28 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSessionImpl.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSessionImpl.java @@ -344,7 +344,7 @@ public static String escapeJupter(String json) { } @Override - public void runPython(String python, String processid, boolean isjoin, String bin, String pyenv, String basedir) { + public void runPython(String python, String processid, boolean isjoin, String bin, String pyenv, String basedir, String token) { this.history_id = new RandomString(12).nextString(); @@ -375,13 +375,26 @@ public void runPython(String python, String processid, boolean isjoin, String bi } - cmdline += "printf \"" + python + "\" > python-" + history_id + ".py; "; + //new version of execution in which all the python files are copied in the host - cmdline += "chmod +x python-" + history_id + ".py;"; + cmdline += "mkdir " + basedir + "/" + token + ";"; + + cmdline += "tar -xvf " + token + ".tar -C " + basedir + "/" + token + "/; "; + + cmdline += "cd "+ basedir + "/" + token + "/; "; + +// cmdline += "printf \"" + python + "\" > python-" + history_id + ".py; "; + + cmdline += "chmod +x *.py;"; + + String filename = ProcessTool.getNameById(processid); + + filename = filename.trim().endsWith(".py")? filename: filename+".py"; if(BaseTool.isNull(bin)||"default".equals(bin)) { - cmdline += "python python-" + history_id + ".py;"; +// cmdline += "python python-" + history_id + ".py;"; + cmdline += "python " + filename + "; "; }else { @@ -389,13 +402,13 @@ public void runPython(String python, String processid, boolean isjoin, String bi cmdline += "source activate " + pyenv + "; "; //for demo only - cmdline += bin + " python-" + history_id + ".py;"; + cmdline += bin + " " + filename + "; "; } cmdline += "echo \"==== Geoweaver Bash Output Finished ====\""; - cmdline += "rm python-" + history_id + ".py;"; + cmdline += "cd ..; rm -R " + token + "*;"; log.info(cmdline); diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/utils/BaseTool.java b/src/edu/gmu/csiss/earthcube/cyberconnector/utils/BaseTool.java index 54d32ea20..845dbbf81 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/utils/BaseTool.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/utils/BaseTool.java @@ -1,5 +1,7 @@ package edu.gmu.csiss.earthcube.cyberconnector.utils; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.DataInputStream; @@ -24,6 +26,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.xml.soap.SOAPException; @@ -40,6 +43,8 @@ import org.dom4j.Node; import org.dom4j.XPath; import org.dom4j.io.SAXReader; +import org.kamranzafar.jtar.TarEntry; +import org.kamranzafar.jtar.TarOutputStream; /** @@ -221,6 +226,48 @@ public static String getCyberConnectorRootPath(){ return rootpath; } + /** + * Zip the files into a tar file + * @param files + * @param targetfile + */ + public static void tar(List files, String targetfile) { + + try { + + // Output file stream + FileOutputStream dest = new FileOutputStream( targetfile ); + + // Create a TarOutputStream + TarOutputStream out = new TarOutputStream( new BufferedOutputStream( dest ) ); + + // Files to tar + for(String fp:files){ + File f = new File(fp); + out.putNextEntry(new TarEntry(f, f.getName())); + BufferedInputStream origin = new BufferedInputStream(new FileInputStream( f )); + int count; + byte data[] = new byte[2048]; + + while((count = origin.read(data)) != -1) { + out.write(data, 0, count); + } + + out.flush(); + origin.close(); + } + + out.close(); + + }catch(Exception e) { + + e.printStackTrace(); + throw new RuntimeException("Fail to tar the files" + e.getLocalizedMessage()); + + } + + } + /** * Get classpath * @return From 649da3c6368730d7a8ef1e3bc901238a9e008e7f Mon Sep 17 00:00:00 2001 From: ZihengSun Date: Wed, 18 Dec 2019 21:08:20 -0500 Subject: [PATCH 3/4] update --- sync.ffs_db | Bin 5825 -> 6266 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/sync.ffs_db b/sync.ffs_db index 46c37050531d996677701d64d20ff8830a2af84e..bb9bda1f2f25c617f5452f3f7f5b1295739b8e39 100644 GIT binary patch delta 6033 zcmV;C7jEdmE&4E!8GrqQkDYs&M>mrCyiK(+b*}+T7ytkR0000$7ytkO0000D6#xKd zKL7v#0001ZUhP}?kKDL&-rUK{ec#FEddLAaX2#=P`^Q;(ymn%*9ryV8#{pYncdJJd zwW8FA|N4Aik<>k711~@j;KA4(v8q@s7K_DVvHB-pef8BM&VQ7(rK-0-VQZ7t>83E1 z{!O;Z%ItJp6Qi1XYbv|QlRrW$G4Y+QqS)l6v3haJvp)cIqs>99JrGU0D2okYX<=)X zWl@$E&2eG3zt@B1DhA|_dyqp~B<5fjD^>pnz^`9DyZ&K$&GGX)jA=O%5v9o&$2|Kj ze7?WFdj94ba)13c8n>}2*6D_1zf3V#?D|}UU8k95S6%EE_Q&k^`|>XG{UTX$V(kZo~ z1)yB!RRtT;)lXqcMP^hI=G@t*%oB6|hk?~XOE71ZMU~#CRwvQ^a#1G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BF&RobDja;jIT~y^<0#6~Z(-Fzi z8?{ Date: Wed, 18 Dec 2019 23:55:33 -0500 Subject: [PATCH 4/4] fix the python run and stop process function --- .../js/edu.gmu.csiss.geoweaver.process.js | 6 ++++- .../cyberconnector/ssh/ProcessTool.java | 10 ++++----- .../cyberconnector/ssh/SSHSession.java | 4 ++-- .../cyberconnector/ssh/SSHSessionImpl.java | 22 +++++++++---------- .../cyberconnector/tools/HistoryTool.java | 6 +++++ 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.process.js b/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.process.js index 8bed00c0d..572c21ea6 100644 --- a/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.process.js +++ b/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.process.js @@ -564,6 +564,10 @@ edu.gmu.csiss.geoweaver.process = { status_col = " Running "; + }else if(status == "Stopped"){ + + status_col = " Stopped "; + }else{ status_col = " Unknown "; @@ -737,7 +741,7 @@ edu.gmu.csiss.geoweaver.process = { // Pending - $("#status_" + history_id).html("Stopped"); + $("#status_" + history_id).html("Stopped"); }else{ diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java index 3a5b8b80d..b9778147e 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/ProcessTool.java @@ -566,7 +566,7 @@ public static String executeShell(String id, String hid, String pswd, String tok if(token == null) { - token = hid; //new RandomString(12).nextString(); + token = new RandomString(12).nextString(); } @@ -574,12 +574,12 @@ public static String executeShell(String id, String hid, String pswd, String tok session.login(hid, pswd, token, false); - GeoweaverController.sshSessionManager.sessionsByToken.put(token, session); - - session.runBash(code, id, isjoin); + session.runBash(code, id, isjoin, token); String historyid = session.getHistory_id(); + GeoweaverController.sshSessionManager.sessionsByToken.put(token, session); + resp = "{\"history_id\": \""+historyid+ "\", \"token\": \""+token+ @@ -646,7 +646,7 @@ public static String executeJupyterProcess(String id, String hid, String pswd, S GeoweaverController.sshSessionManager.sessionsByToken.put(token, session); - session.runJupyter(code, id, isjoin, bin, pyenv, basedir); + session.runJupyter(code, id, isjoin, bin, pyenv, basedir, token); String historyid = session.getHistory_id(); diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSession.java b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSession.java index dafa9e745..496d9c6a6 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSession.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSession.java @@ -73,9 +73,9 @@ public interface SSHSession { public void setWebSocketSession(WebSocketSession session); - public void runBash(String script, String processid, boolean isjoin); + public void runBash(String script, String processid, boolean isjoin, String token); - public void runJupyter(String script, String processid, boolean isjoin, String bin, String env, String basedir); + public void runJupyter(String script, String processid, boolean isjoin, String bin, String env, String basedir, String token); public void runPython(String script, String processid, boolean isjoin, String bin, String pyenv, String basedir, String token); diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSessionImpl.java b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSessionImpl.java index de882bd28..821802218 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSessionImpl.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/ssh/SSHSessionImpl.java @@ -56,13 +56,13 @@ public class SSHSessionImpl implements SSHSession { protected final Logger log = LoggerFactory.getLogger(getClass()); - private SSHClient ssh; + private SSHClient ssh; //SSHJ creates a new client private String hostid; - private Session session; //sshj session + private Session session; //SSHJ client creates SSHJ session - private Shell shell; + private Shell shell; //SSHJ session creates SSHJ shell private String username; @@ -166,7 +166,7 @@ public boolean login(String host, String port, String username, String password, logout(); // ssh.authPublickey(System.getProperty("user.name")); log.info("new SSHClient"); - ssh = new SSHClient(); + ssh = new SSHClient(); //create a new SSH client log.info("verify all hosts"); ssh.addHostKeyVerifier(new HostKeyVerifier() { public boolean verify(String arg0, int arg1, PublicKey arg2) { @@ -178,7 +178,7 @@ public boolean verify(String arg0, int arg1, PublicKey arg2) { log.info("authenticating: {}", username); ssh.authPassword(username, password); log.info("starting session"); - session = ssh.startSession(); + session = ssh.startSession(); //SSH client creates new SSH session log.info("allocating PTY"); session.allocateDefaultPTY(); this.username = username; @@ -188,7 +188,7 @@ public boolean verify(String arg0, int arg1, PublicKey arg2) { if(isShell) { //shell log.info("starting shell"); - shell = session.startShell(); //if shell is null, it is in command mode. + shell = session.startShell(); //SSH session creates SSH Shell. if shell is null, it is in command mode. log.info("SSH session established"); input = new BufferedReader(new InputStreamReader(shell.getInputStream())); output = shell.getOutputStream(); @@ -346,7 +346,7 @@ public static String escapeJupter(String json) { @Override public void runPython(String python, String processid, boolean isjoin, String bin, String pyenv, String basedir, String token) { - this.history_id = new RandomString(12).nextString(); + this.history_id = token; //new RandomString(12).nextString(); this.history_process = processid.split("-")[0]; //only retain process id, remove object id @@ -459,9 +459,9 @@ public void runPython(String python, String processid, boolean isjoin, String bi } @Override - public void runJupyter(String notebookjson, String processid, boolean isjoin, String bin, String pyenv, String basedir) { + public void runJupyter(String notebookjson, String processid, boolean isjoin, String bin, String pyenv, String basedir, String token) { - this.history_id = new RandomString(12).nextString(); + this.history_id = token; //new RandomString(12).nextString(); this.history_process = processid.split("-")[0]; //only retain process id, remove object id @@ -558,9 +558,9 @@ public void runJupyter(String notebookjson, String processid, boolean isjoin, St } @Override - public void runBash(String script, String processid, boolean isjoin) { + public void runBash(String script, String processid, boolean isjoin, String token) { - this.history_id = new RandomString(12).nextString(); + this.history_id = token; //new RandomString(12).nextString(); this.history_process = processid.split("-")[0]; //only retain process id, remove object id diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/tools/HistoryTool.java b/src/edu/gmu/csiss/earthcube/cyberconnector/tools/HistoryTool.java index 5a721b3ac..ef70bda62 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/tools/HistoryTool.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/tools/HistoryTool.java @@ -1,7 +1,9 @@ package edu.gmu.csiss.earthcube.cyberconnector.tools; import edu.gmu.csiss.earthcube.cyberconnector.database.DataBaseOperation; +import edu.gmu.csiss.earthcube.cyberconnector.ssh.SSHSession; import edu.gmu.csiss.earthcube.cyberconnector.utils.BaseTool; +import edu.gmu.csiss.earthcube.cyberconnector.web.GeoweaverController; public class HistoryTool { @@ -13,6 +15,10 @@ public static void stop(String history_id) { try { + SSHSession session = GeoweaverController.sshSessionManager.sessionsByToken.get(history_id); + + session.getSsh().close(); //this line close the shell session and the associated command is stopped + String history_end_time = BaseTool.getCurrentMySQLDatetime(); StringBuffer sql = new StringBuffer("update history set end_time = '");