This commit is contained in:
Nunzio Andrea Galante 2017-02-21 09:59:25 +00:00
parent 98c84e35aa
commit 6c282d1754
5 changed files with 32 additions and 6 deletions

View File

@ -1,7 +1,10 @@
package org.gcube.dataanalysis.dataminer.poolmanager.ansible;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import org.gcube.dataanalysis.dataminer.poolmanager.ansible.model.Inventory;
import org.gcube.dataanalysis.dataminer.poolmanager.ansible.model.Playbook;
@ -62,7 +65,7 @@ public class AnsibleWorker {
public void removeWorkStructure() {
// remove the working dir
// this.getWorkdir().delete();
//this.getWorkdir().delete();
}
public File getPlaybookFile() {
@ -91,9 +94,21 @@ public class AnsibleWorker {
public void apply() {
public void apply() throws IOException {
// TODO execute the playbook and return output
System.out.println("TODO: execute: ansible-playbook -v -i " + this.getInventoryFile().getName() + " " + this.getPlaybookFile().getName());
try {
System.out.println("ansible-playbook -v -i " + this.getInventoryFile().getName() + " " + this.getPlaybookFile().getName());
Process p = Runtime.getRuntime().exec("ansible-playbook -v -i " + this.getInventoryFile().getName() + " " + this.getPlaybookFile().getName());
BufferedReader in = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
//System.out.println("TODO: execute: ansible-playbook -v -i " + this.getInventoryFile().getName() + " " + this.getPlaybookFile().getName());
}
/**

View File

@ -202,8 +202,10 @@ public class AnsibleBridge {
FileOutputStream fos = new FileOutputStream(n);
PrintStream ps = new PrintStream(fos);
System.setOut(ps);
System.setErr(ps);
worker.apply();
System.setOut(console);
System.setErr(console);
worker.apply();
System.out.println("Log stored to to " + n.getAbsolutePath());

View File

@ -8,6 +8,8 @@ import java.util.List;
import java.util.Vector;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Domain;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Host;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
@ -27,7 +29,8 @@ public class ISClient {
if (!remote) {
Collection<Host> out = new Vector<>();
Host h = new Host();
h.setName("bb-dataminer.res.eng.it");
//h.setName("bb-dataminer.res.eng.it");
h.setName("vm123.ui.savba.sk");
out.add(h);
return out;
} else {
@ -51,4 +54,9 @@ public class ISClient {
}
}
// public static void main(String[] args) {
// ISClient a = new ISClient();
// ScopeProvider.instance.set("/gcube/devNext/NextNext");
// System.out.println(a.listDataminersInVRE());
//}
}

View File

@ -10,6 +10,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
import org.gcube.dataanalysis.dataminer.poolmanager.service.DataminerPoolManager;
import org.slf4j.Logger;
@ -57,6 +58,7 @@ public class RestPoolManager implements PoolManager {
public static void main(String[] args) throws IOException, InterruptedException {
RestPoolManager a = new RestPoolManager();
ScopeProvider.instance.set("/gcube/devNext/NextNext");
a.addAlgorithmToVRE("http://data.d4science.org/R0FqV2lNOW1jMkxuUEIrWXY4aUhvSENHSmVMQks4NjdHbWJQNStIS0N6Yz0", "/gcube/devNext/NextNext");
//System.out.println(a.getLogById("dadcb059-69e5-48c3-aa58-3b290ae0419d"));
}

View File

@ -207,7 +207,7 @@ public class DataminerPoolManager implements PoolManager {
};
new Thread(r).start();
//this line will execute immediately, not waiting for your task to complete
System.out.println(uuid);
System.out.println(uuid);
return uuid;
}
@ -235,7 +235,6 @@ public class DataminerPoolManager implements PoolManager {
// apply the changes
AnsibleBridge a = new AnsibleBridge();
return a.applyAlgorithmSetToCluster(algorithms, cluster,uuid).getWorkerId();
}