117 lines
3.8 KiB
Java
117 lines
3.8 KiB
Java
package org.gcube.dataanalysis.dataminer.poolmanager.service;
|
|
|
|
import java.io.File;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.PrintWriter;
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
***REMOVED***
|
|
***REMOVED***
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
|
|
***REMOVED***
|
|
***REMOVED***
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.NotificationHelper;
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail;
|
|
|
|
public class ProductionPublishingJob extends DMPMJob {
|
|
|
|
private Algorithm algorithm;
|
|
***REMOVED***private Cluster prodCluster;
|
|
private String targetVREName;
|
|
private String category;
|
|
private String algorithm_type;
|
|
***REMOVED***private String targetVREToken;
|
|
private String env;
|
|
|
|
|
|
public ProductionPublishingJob(SVNUpdater svnUpdater, Algorithm algorithm,
|
|
/*Cluster prodCluster,*/ String targetVREName, String category,String algorithm_type, String env) throws FileNotFoundException, UnsupportedEncodingException {
|
|
super(svnUpdater);
|
|
this.algorithm = algorithm;
|
|
***REMOVED***this.prodCluster = prodCluster;
|
|
this.targetVREName = targetVREName;
|
|
this.category = category;
|
|
this.algorithm_type = algorithm_type;
|
|
***REMOVED***this.targetVREToken = targetVREToken;
|
|
this.env= env;
|
|
|
|
|
|
this.jobLogs = new File(System.getProperty("user.home") + File.separator + "dataminer-pool-manager" + File.separator + "jobs");
|
|
this.jobLogs.mkdirs();
|
|
***REMOVED***
|
|
|
|
@Override
|
|
protected void execute() {
|
|
SendMail sm = new SendMail();
|
|
NotificationHelper nh = new NotificationHelper();
|
|
try {
|
|
|
|
***REMOVED***if (CheckPermission.apply(targetVREToken,targetVREName)){
|
|
|
|
***REMOVED***this.svnUpdater.updateProdDeps(this.algorithm);
|
|
this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.targetVREName, this.category,this.algorithm_type, this.algorithm.getFullname(), env);
|
|
this.getStatus(9);
|
|
sm.sendNotification(nh.getSuccessSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getSuccessBodyRelease("\n\n"+this.buildInfo()));
|
|
return;
|
|
***REMOVED******REMOVED***
|
|
***REMOVED***else this.getStatus(0);
|
|
***REMOVED***sm.sendNotification(nh.getFailedSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getFailedBodyRelease(" The user "+this.algorithm.getFullname()+ " is not authorized to access to the "+ targetVREName+ " VRE"+"\n\n"+this.buildInfo()));
|
|
***REMOVED***return;
|
|
***REMOVED*** int ret = this.executeAnsibleWorker(
|
|
***REMOVED*** createWorker(this.algorithm, this.prodCluster, false, "gcube"));
|
|
|
|
***REMOVED*** catch (Exception e) {
|
|
try {
|
|
this.getStatus(0);
|
|
***REMOVED*** catch (FileNotFoundException e1) {
|
|
***REMOVED*** TODO Auto-generated catch block
|
|
e1.printStackTrace();
|
|
***REMOVED*** catch (UnsupportedEncodingException e1) {
|
|
***REMOVED*** TODO Auto-generated catch block
|
|
e1.printStackTrace();
|
|
***REMOVED***
|
|
e.printStackTrace();
|
|
***REMOVED***
|
|
***REMOVED***
|
|
|
|
|
|
public String getStatus(int exitstatus) throws FileNotFoundException, UnsupportedEncodingException {
|
|
|
|
File m = new File(this.jobLogs + File.separator + this.id+"_exitStatus");
|
|
PrintWriter writer = new PrintWriter(m, "UTF-8");
|
|
|
|
String response = "";
|
|
|
|
if (exitstatus == 9) {
|
|
response = "COMPLETED";
|
|
writer.println(response);
|
|
***REMOVED***
|
|
|
|
if (exitstatus == 0) {
|
|
response = "FAILED";
|
|
writer.println(response);
|
|
***REMOVED***writer.close();
|
|
***REMOVED***
|
|
|
|
|
|
writer.close();
|
|
return response;
|
|
***REMOVED***
|
|
|
|
|
|
public String buildInfo(){
|
|
return
|
|
"\n"+
|
|
"Algorithm details:\n"+"\n"+
|
|
"User: "+this.algorithm.getFullname()+"\n"+
|
|
"Algorithm name: "+this.algorithm.getName()+"\n"+
|
|
"Caller VRE: "+ScopeProvider.instance.get()+"\n"+
|
|
"Target VRE: "+targetVREName+"\n";
|
|
***REMOVED***
|
|
|
|
|
|
|
|
|
|
***REMOVED***
|