git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@151222 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1217ed589b
commit
a6d01da01a
|
@ -1,11 +1,18 @@
|
||||||
package org.gcube.dataanalysis.dataminer.poolmanager.service;
|
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***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.CheckPermission;
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.CheckPermission;
|
||||||
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.NotificationHelper;
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
|
||||||
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail;
|
||||||
|
|
||||||
public class ProductionPublishingJob extends DMPMJob ***REMOVED***
|
public class ProductionPublishingJob extends DMPMJob ***REMOVED***
|
||||||
|
|
||||||
|
@ -14,26 +21,33 @@ public class ProductionPublishingJob extends DMPMJob ***REMOVED***
|
||||||
private String targetVREName;
|
private String targetVREName;
|
||||||
private String targetVREToken;
|
private String targetVREToken;
|
||||||
|
|
||||||
public ProductionPublishingJob(SVNUpdater svnUpdater, Algorithm algorithm, /*Cluster prodCluster,*/ String targetVREName, String targetVREToken) ***REMOVED***
|
public ProductionPublishingJob(SVNUpdater svnUpdater, Algorithm algorithm, /*Cluster prodCluster,*/ String targetVREName, String targetVREToken) throws FileNotFoundException, UnsupportedEncodingException ***REMOVED***
|
||||||
super(svnUpdater);
|
super(svnUpdater);
|
||||||
this.algorithm = algorithm;
|
this.algorithm = algorithm;
|
||||||
***REMOVED***this.prodCluster = prodCluster;
|
***REMOVED***this.prodCluster = prodCluster;
|
||||||
this.targetVREName = targetVREName;
|
this.targetVREName = targetVREName;
|
||||||
this.targetVREToken = targetVREToken;
|
this.targetVREToken = targetVREToken;
|
||||||
|
|
||||||
|
|
||||||
|
this.jobLogs = new File(System.getProperty("user.home") + File.separator + "dataminer-pool-manager" + File.separator + "jobs");
|
||||||
|
this.jobLogs.mkdirs();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
protected void execute() ***REMOVED***
|
protected void execute() ***REMOVED***
|
||||||
|
SendMail sm = new SendMail();
|
||||||
|
NotificationHelper nh = new NotificationHelper();
|
||||||
try ***REMOVED***
|
try ***REMOVED***
|
||||||
|
|
||||||
if (CheckPermission.apply(targetVREToken,targetVREName))***REMOVED***
|
if (CheckPermission.apply(targetVREToken,targetVREName))***REMOVED***
|
||||||
|
|
||||||
***REMOVED***this.svnUpdater.updateProdDeps(this.algorithm);
|
***REMOVED***this.svnUpdater.updateProdDeps(this.algorithm);
|
||||||
|
|
||||||
this.svnUpdater.updateSVNProdAlgorithmList(this.algorithm, this.targetVREName, this.algorithm.getFullname(), "Prod");
|
this.svnUpdater.updateSVNProdAlgorithmList(this.algorithm, this.targetVREName, this.algorithm.getFullname(), "Prod");
|
||||||
|
this.getStatus(9);
|
||||||
|
sm.sendNotification(nh.getSuccessSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getSuccessBodyRelease(this.buildInfo()));
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
***REMOVED*** int ret = this.executeAnsibleWorker(
|
***REMOVED*** int ret = this.executeAnsibleWorker(
|
||||||
***REMOVED*** createWorker(this.algorithm, this.prodCluster, false, "gcube"));
|
***REMOVED*** createWorker(this.algorithm, this.prodCluster, false, "gcube"));
|
||||||
|
|
||||||
|
@ -43,5 +57,34 @@ public class ProductionPublishingJob extends DMPMJob ***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
public String getStatus(int exitstatus) throws FileNotFoundException, UnsupportedEncodingException ***REMOVED***
|
||||||
|
|
||||||
|
File m = new File(this.jobLogs + File.separator + this.id);
|
||||||
|
PrintWriter writer = new PrintWriter(m, "UTF-8");
|
||||||
|
|
||||||
|
String response = "";
|
||||||
|
|
||||||
|
if (exitstatus == 9) ***REMOVED***
|
||||||
|
response = "SVN REPOSITORY CORRECTLY UPDATED; THE CRON JOB WILL INSTALL THE ALGORITHM "+ this.algorithm.getName() + " IN THE VRE" + targetVREName;
|
||||||
|
writer.println(response);
|
||||||
|
writer.close();
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
return response;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
public String buildInfo()***REMOVED***
|
||||||
|
return
|
||||||
|
"\n"+
|
||||||
|
"\n"+
|
||||||
|
"User: "+this.algorithm.getFullname()+"\n"+
|
||||||
|
"Algorithm name: "+this.algorithm.getName()+"\n"+
|
||||||
|
"Caller VRE: "+ScopeProvider.instance.get()+"\n"+
|
||||||
|
"Target VRE: "+ targetVREToken;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class StagingJob extends DMPMJob ***REMOVED***
|
||||||
message += "\n" + n;
|
message += "\n" + n;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody(message));
|
sm.sendNotification(nh.getFailedSubject() +" for "+this.algorithm.getName()+ " algorithm", nh.getFailedBody(this.buildInfo()+message));
|
||||||
return;
|
return;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class StagingJob extends DMPMJob ***REMOVED***
|
||||||
|
|
||||||
if (ret != 0) ***REMOVED***
|
if (ret != 0) ***REMOVED***
|
||||||
this.getStatus(2);
|
this.getStatus(2);
|
||||||
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody("Installation failed. Return code=" + ret));
|
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm", nh.getFailedBody(this.buildInfo()+"Installation failed. Return code=" + ret));
|
||||||
return;
|
return;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
@ -92,12 +92,13 @@ public class StagingJob extends DMPMJob ***REMOVED***
|
||||||
this.algorithm.getFullname(), "Proto");
|
this.algorithm.getFullname(), "Proto");
|
||||||
|
|
||||||
this.getStatus(9);
|
this.getStatus(9);
|
||||||
sm.sendNotification(nh.getSuccessSubject(), nh.getSuccessBody());
|
sm.sendNotification(nh.getSuccessSubject() + "for "+this.algorithm.getName()+ " algorithm", nh.getSuccessBody(this.buildInfo()));
|
||||||
return;
|
return;
|
||||||
***REMOVED*** else
|
***REMOVED*** else
|
||||||
this.getStatus(2);
|
this.getStatus(2);
|
||||||
sm.sendNotification(nh.getFailedSubject(),
|
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm",
|
||||||
nh.getFailedBody(
|
nh.getFailedBody(
|
||||||
|
this.buildInfo()+"\n"+
|
||||||
"Installation completed but DataMiner Interface not working correctly or files "
|
"Installation completed but DataMiner Interface not working correctly or files "
|
||||||
+ this.algorithm.getName() + ".jar and " + this.algorithm.getName()
|
+ this.algorithm.getName() + ".jar and " + this.algorithm.getName()
|
||||||
+ "_interface.jar not availables at the expected path"));
|
+ "_interface.jar not availables at the expected path"));
|
||||||
|
@ -136,4 +137,17 @@ public class StagingJob extends DMPMJob ***REMOVED***
|
||||||
return response;
|
return response;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
public String buildInfo()***REMOVED***
|
||||||
|
ServiceConfiguration a = new ServiceConfiguration();
|
||||||
|
return
|
||||||
|
"\n"+
|
||||||
|
"\n"+
|
||||||
|
"User: "+this.algorithm.getFullname()+"\n"+
|
||||||
|
"Algorithm name: "+this.algorithm.getName()+"\n"+
|
||||||
|
"Staging DataMiner Host: "+ a.getStagingHost()+
|
||||||
|
"Caller VRE: "+rProtoVREName+
|
||||||
|
"Target VRE: "+rProtoVREName;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -17,10 +17,10 @@ public class CheckPermission ***REMOVED***
|
||||||
|
|
||||||
AuthorizationEntry entry = authorizationService().get(VREToken);
|
AuthorizationEntry entry = authorizationService().get(VREToken);
|
||||||
if (entry.getContext().equals(vre)) ***REMOVED***
|
if (entry.getContext().equals(vre)) ***REMOVED***
|
||||||
System.out.println("OK!");
|
System.out.println("Authorization OK!");
|
||||||
return true;
|
return true;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
System.out.println("Not a valid token recognized for the VRE: "+vre);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -17,6 +17,10 @@ public class NotificationHelper ***REMOVED***
|
||||||
private String getSubjectHeader() ***REMOVED***
|
private String getSubjectHeader() ***REMOVED***
|
||||||
return "[DataMinerGhostInstallationRequestReport]";
|
return "[DataMinerGhostInstallationRequestReport]";
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
private String getSubjectHeaderRelease() ***REMOVED***
|
||||||
|
return "[DataMinerReleaseInstallationRequestReport]";
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
private boolean isError() ***REMOVED***
|
private boolean isError() ***REMOVED***
|
||||||
return this.executionException!=null;
|
return this.executionException!=null;
|
||||||
|
@ -30,13 +34,23 @@ public class NotificationHelper ***REMOVED***
|
||||||
return this.getSubjectHeader()+" is SUCCESS";
|
return this.getSubjectHeader()+" is SUCCESS";
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
public String getSuccessSubjectRelease() ***REMOVED***
|
||||||
|
return this.getSubjectHeaderRelease()+" is SUCCESS";
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
public String getFailedSubjectRelease() ***REMOVED***
|
||||||
|
return this.getSubjectHeaderRelease()+" is FAILED";
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
public String getFailedSubject() ***REMOVED***
|
public String getFailedSubject() ***REMOVED***
|
||||||
return String.format(this.getSubjectHeader()+" is FAILED");
|
return String.format(this.getSubjectHeader()+" is FAILED");
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
public String getSuccessBody() ***REMOVED***
|
public String getSuccessBody(String info) ***REMOVED***
|
||||||
String message = String.format("The installation of the algorithm in the ghost dataminer is completed successfully.");
|
String message = String.format("The installation of the algorithm in the ghost dataminer is completed successfully.");
|
||||||
message+="\n\nYou can retrieve experiment results under the '/DataMiner' e-Infrastructure Workspace folder or from the DataMiner interface.";
|
message+="\n\nYou can retrieve experiment results under the '/DataMiner' e-Infrastructure Workspace folder or from the DataMiner interface.\n\n"+ info;
|
||||||
return message;
|
return message;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
@ -46,6 +60,12 @@ public class NotificationHelper ***REMOVED***
|
||||||
return body;
|
return body;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
public String getSuccessBodyRelease(String info) ***REMOVED***
|
||||||
|
String message = String.format("SVN REPOSITORY CORRECTLY UPDATED.");
|
||||||
|
message+="\n\n The CRON job will install the algorithm in the target VRE \n\n"+ info;
|
||||||
|
return message;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
***REMOVED*** public String getSubject() ***REMOVED***
|
***REMOVED*** public String getSubject() ***REMOVED***
|
||||||
***REMOVED*** if(this.isError()) ***REMOVED***
|
***REMOVED*** if(this.isError()) ***REMOVED***
|
||||||
***REMOVED*** return this.getFailedSubject();
|
***REMOVED*** return this.getFailedSubject();
|
||||||
|
|
Loading…
Reference in New Issue