dataminer-pool-manager/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java

83 lines
2.9 KiB
Java

package org.gcube.dataanalysis.dataminer.poolmanager.service;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.util.Collection;
import org.gcube.common.authorization.library.AuthorizationEntry;
***REMOVED***
***REMOVED***
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
import org.gcube.dataanalysis.dataminer.poolmanager.util.CheckMethod;
import org.gcube.dataanalysis.dataminer.poolmanager.util.NotificationHelper;
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail;
import org.gcube.dataanalysis.dataminer.poolmanager.util.ServiceConfiguration;
public class StagingJob extends DMPMJob ***REMOVED***
private Algorithm algorithm;
private Cluster stagingCluster;
private Cluster rProtoCluster;
private String rProtoVREName;
public StagingJob(SVNUpdater svnUpdater, Algorithm algorithm, Cluster stagingCluster, Cluster rProtoCluster,
String rProtoVREName) ***REMOVED***
super(svnUpdater);
this.algorithm = algorithm;
this.stagingCluster = stagingCluster;
this.rProtoCluster = rProtoCluster;
this.rProtoVREName = rProtoVREName;
***REMOVED***
***REMOVED***
protected void execute() ***REMOVED***
ServiceConfiguration a = new ServiceConfiguration();
CheckMethod b = new CheckMethod();
SendMail sm = new SendMail();
NotificationHelper nh = new NotificationHelper();
try ***REMOVED***
Collection<String> undefinedDependencies = this.svnUpdater.getUndefinedDependencies(
this.svnUpdater.getRProtoDependencyFile(this.algorithm.getLanguage()), this.algorithm.getDependencies());
if (!undefinedDependencies.isEmpty()) ***REMOVED***
String message = "Following dependencies are not defined:\n";
for (String n : undefinedDependencies) ***REMOVED***
message += "\n" + n;
***REMOVED***
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody(message));
return;
***REMOVED***
int ret = this.executeAnsibleWorker(createWorker(this.algorithm, this.stagingCluster, false, "root"));
if (ret == 0) ***REMOVED***
if (b.checkMethod(a.getStagingHost(), SecurityTokenProvider.instance.get())
&& (b.algoExists(this.algorithm))) ***REMOVED***
sm.sendNotification(nh.getSuccessSubject(), nh.getSuccessBody());
***REMOVED*** this.svnUpdater.updateRPRotoDeps(this.algorithm);
this.svnUpdater.updateSVNRProtoAlgorithmList(this.algorithm, this.rProtoVREName,
this.algorithm.getFullname(), "Proto");
***REMOVED*** int ret2 = this.executeAnsibleWorker(
***REMOVED*** createWorker(this.algorithm, this.rProtoCluster,
***REMOVED*** false, "gcube"));
***REMOVED***
***REMOVED*** else
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody("Installation failed. Return code=" + ret));
***REMOVED*** catch (Exception e) ***REMOVED***
e.printStackTrace();
***REMOVED***
***REMOVED***
***REMOVED***