2017-05-12 17:32:14 +02:00
|
|
|
package org.gcube.dataanalysis.dataminer.poolmanager.service;
|
|
|
|
|
2017-06-19 18:34:44 +02:00
|
|
|
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
|
|
|
|
2017-07-06 17:34:45 +02:00
|
|
|
import java.util.Collection;
|
|
|
|
|
2017-06-19 18:34:44 +02:00
|
|
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
2017-06-30 15:49:04 +02:00
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
2017-05-12 17:32:14 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
|
2017-06-30 15:49:04 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.CheckMethod;
|
2017-07-06 17:34:45 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.NotificationHelper;
|
2017-05-12 17:32:14 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
|
2017-07-06 14:54:04 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail;
|
2017-06-30 15:49:04 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.ServiceConfiguration;
|
2017-05-12 17:32:14 +02:00
|
|
|
|
|
|
|
public class StagingJob extends DMPMJob {
|
2017-07-06 17:34:45 +02:00
|
|
|
|
2017-05-12 17:32:14 +02:00
|
|
|
private Algorithm algorithm;
|
|
|
|
private Cluster stagingCluster;
|
2017-07-06 18:44:03 +02:00
|
|
|
//private Cluster rProtoCluster;
|
2017-05-17 18:16:25 +02:00
|
|
|
private String rProtoVREName;
|
2017-05-12 17:32:14 +02:00
|
|
|
|
2017-07-06 18:44:03 +02:00
|
|
|
public StagingJob(SVNUpdater svnUpdater, Algorithm algorithm, Cluster stagingCluster, /*Cluster rProtoCluster,*/
|
2017-05-17 18:16:25 +02:00
|
|
|
String rProtoVREName) {
|
2017-05-12 17:32:14 +02:00
|
|
|
super(svnUpdater);
|
|
|
|
this.algorithm = algorithm;
|
|
|
|
this.stagingCluster = stagingCluster;
|
2017-07-06 18:44:03 +02:00
|
|
|
//this.rProtoCluster = rProtoCluster;
|
2017-05-17 18:16:25 +02:00
|
|
|
this.rProtoVREName = rProtoVREName;
|
2017-05-12 17:32:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void execute() {
|
2017-06-30 15:49:04 +02:00
|
|
|
ServiceConfiguration a = new ServiceConfiguration();
|
|
|
|
CheckMethod b = new CheckMethod();
|
2017-07-06 14:54:04 +02:00
|
|
|
SendMail sm = new SendMail();
|
2017-07-06 17:34:45 +02:00
|
|
|
NotificationHelper nh = new NotificationHelper();
|
2017-07-05 17:50:42 +02:00
|
|
|
|
2017-05-12 17:32:14 +02:00
|
|
|
try {
|
2017-07-05 17:50:42 +02:00
|
|
|
|
2017-07-06 17:34:45 +02:00
|
|
|
Collection<String> undefinedDependencies = this.svnUpdater.getUndefinedDependencies(
|
|
|
|
this.svnUpdater.getRProtoDependencyFile(this.algorithm.getLanguage()), this.algorithm.getDependencies());
|
|
|
|
|
|
|
|
if (!undefinedDependencies.isEmpty()) {
|
|
|
|
|
|
|
|
String message = "Following dependencies are not defined:\n";
|
|
|
|
for (String n : undefinedDependencies) {
|
|
|
|
message += "\n" + n;
|
|
|
|
}
|
|
|
|
|
|
|
|
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody(message));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ret = this.executeAnsibleWorker(createWorker(this.algorithm, this.stagingCluster, false, "root"));
|
|
|
|
|
|
|
|
if (ret == 0) {
|
2017-07-05 17:50:42 +02:00
|
|
|
|
2017-07-06 17:34:45 +02:00
|
|
|
if (b.checkMethod(a.getStagingHost(), SecurityTokenProvider.instance.get())
|
|
|
|
&& (b.algoExists(this.algorithm))) {
|
2017-07-05 17:50:42 +02:00
|
|
|
|
2017-07-06 17:34:45 +02:00
|
|
|
sm.sendNotification(nh.getSuccessSubject(), nh.getSuccessBody());
|
|
|
|
// this.svnUpdater.updateRPRotoDeps(this.algorithm);
|
2017-07-05 17:50:42 +02:00
|
|
|
|
2017-07-06 17:34:45 +02:00
|
|
|
this.svnUpdater.updateSVNRProtoAlgorithmList(this.algorithm, this.rProtoVREName,
|
|
|
|
this.algorithm.getFullname(), "Proto");
|
2017-07-05 17:50:42 +02:00
|
|
|
|
2017-07-06 17:34:45 +02:00
|
|
|
// int ret2 = this.executeAnsibleWorker(
|
|
|
|
// createWorker(this.algorithm, this.rProtoCluster,
|
|
|
|
// false, "gcube"));
|
2017-06-30 15:49:04 +02:00
|
|
|
}
|
2017-07-06 17:34:45 +02:00
|
|
|
} else
|
|
|
|
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody("Installation failed. Return code=" + ret));
|
2017-07-05 17:50:42 +02:00
|
|
|
|
2017-05-12 17:32:14 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|