103 lines
3.5 KiB
Java
103 lines
3.5 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 targetVREToken;
|
|
private String env;
|
|
|
|
|
|
public ProductionPublishingJob(SVNUpdater svnUpdater, Algorithm algorithm, /*Cluster prodCluster,*/ String targetVREName, String targetVREToken, String env) throws FileNotFoundException, UnsupportedEncodingException {
|
|
super(svnUpdater);
|
|
this.algorithm = algorithm;
|
|
***REMOVED***this.prodCluster = prodCluster;
|
|
this.targetVREName = targetVREName;
|
|
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 {
|
|
|
|
if (CheckPermission.apply(targetVREToken,targetVREName)){
|
|
|
|
***REMOVED***this.svnUpdater.updateProdDeps(this.algorithm);
|
|
this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.targetVREName, this.algorithm.getFullname(), env);
|
|
this.getStatus(9);
|
|
sm.sendNotification(nh.getSuccessSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getSuccessBodyRelease(this.buildInfo()));
|
|
return;
|
|
***REMOVED***
|
|
else this.getStatus(0);
|
|
sm.sendNotification(nh.getFailedSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getFailedBodyRelease(this.buildInfo()+" The user "+this.algorithm.getFullname()+ " is not authorized to access to the "+ targetVREName+ " VRE"));
|
|
return;
|
|
***REMOVED*** int ret = this.executeAnsibleWorker(
|
|
***REMOVED*** createWorker(this.algorithm, this.prodCluster, false, "gcube"));
|
|
|
|
***REMOVED*** catch (Exception e) {
|
|
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 = "SVN REPOSITORY CORRECTLY UPDATED; THE CRON JOB WILL INSTALL THE ALGORITHM "+ this.algorithm.getName() + " IN THE VRE " + targetVREName;
|
|
writer.println(response);
|
|
***REMOVED***
|
|
|
|
if (exitstatus == 0) {
|
|
response = "SVN REPOSITORY UPDATE FAI; THE CRON JOB WILL NOT BE ABLE TO INSTALL THE ALGORITHM "+this.algorithm.getName()+" IN THE VRE " + targetVREName;;
|
|
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***
|