This commit is contained in:
Nunzio Andrea Galante 2017-07-17 21:52:54 +00:00
parent 1facaa8482
commit 6e05178ecc
3 changed files with 91 additions and 7 deletions

10
pom.xml
View File

@ -81,6 +81,16 @@
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
<!-- https:***REMOVED***mvnrepository.com/artifact/com.jcraft/jsch -->
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>

View File

@ -91,6 +91,9 @@ public class StagingJob extends DMPMJob ***REMOVED***
if (b.checkMethod(a.getStagingHost(), SecurityTokenProvider.instance.get())
&& (b.algoExists(this.algorithm))) ***REMOVED***
System.out.println("Interface check ok!");
System.out.println("Both the files exist at the correct path!");
this.svnUpdater.updateSVNRProtoAlgorithmList(this.algorithm, this.rProtoVREName,
this.algorithm.getFullname(), "Proto");

View File

@ -3,11 +3,23 @@ package org.gcube.dataanalysis.dataminer.poolmanager.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
***REMOVED***
import java.util.Vector;
import javax.jms.ServerSession;
***REMOVED***
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpATTRS;
import com.jcraft.jsch.SftpException;
public class CheckMethod ***REMOVED***
public CheckMethod() ***REMOVED***
@ -70,27 +82,86 @@ public class CheckMethod ***REMOVED***
public boolean algoExists(Algorithm a)***REMOVED***
public boolean algoExists(Algorithm a) throws Exception***REMOVED***
File file = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+".jar");
File file2 = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+"_interface.jar");
if (file.exists()&&(file2.exists()))***REMOVED***
System.out.println("First file is located to: "+file.getPath());
System.out.println("Second file is located to: "+file2.getPath());
if ((this.doesExist(file.getPath())) && (this.doesExist(file2.getPath())))***REMOVED***
return true;
***REMOVED***
else
System.out.println("Algorithm"+a.getName()+".jar"+ " and "+a.getName()+"interface_.jar files are not present at the expected path");
System.out.println("Algorithm "+a.getName()+".jar"+ " and "+a.getName()+"_interface.jar files are not present at the expected path");
return false;
***REMOVED***
public boolean doesExist(String path) throws Exception ***REMOVED***
JSch jsch = new JSch();
Session session = null;
Channel channel = null;
ChannelSftp c = null;
boolean success = false;
jsch.setKnownHosts("~/.ssh/known_hosts");
String privateKey = "~/.ssh/id_rsa";
jsch.addIdentity(privateKey);
System.out.println("Private Key Added.");
session = jsch.getSession("root", "dataminer1-devnext.d4science.org");
System.out.println("session created.");
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
channel = session.openChannel("sftp");
channel.connect();
System.out.println("shell channel connected....");
c = (ChannelSftp) channel;
SftpATTRS is = null;
System.out.println(path);
try ***REMOVED***
is = c.lstat(path);
success = true;
***REMOVED*** catch (SftpException e) ***REMOVED***
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) ***REMOVED***
***REMOVED*** file doesn't exist
success = false;
***REMOVED***
***REMOVED***success = true; ***REMOVED*** something else went wrong
***REMOVED***
c.disconnect();
session.disconnect();
return success;
***REMOVED***
public static void main(String[] args) throws Exception ***REMOVED***
***REMOVED*** ServiceConfiguration a = new ServiceConfiguration();
***REMOVED*** System.out.println(a.getStagingHost());
CheckMethod a = new CheckMethod();
if (!a.checkMethod("dataminer1-devnext.d4science.org", "***REMOVED***"))***REMOVED***
System.out.println("ciao");***REMOVED***
***REMOVED*** if (a.checkMethod("dataminer1-devnext.d4science.org", "***REMOVED***"))***REMOVED***
***REMOVED*** System.out.println("ciao");***REMOVED***
***REMOVED***
if (a.doesExist("/home/gcube/wps_algorithms/algorithms/XMEANS_interface.jar"))***REMOVED***
System.out.println("ciao");
***REMOVED***
***REMOVED***
***REMOVED***