git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@142822 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
98c84e35aa
commit
6c282d1754
|
@ -1,7 +1,10 @@
|
||||||
package org.gcube.dataanalysis.dataminer.poolmanager.ansible;
|
package org.gcube.dataanalysis.dataminer.poolmanager.ansible;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
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.Inventory;
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.ansible.model.Playbook;
|
import org.gcube.dataanalysis.dataminer.poolmanager.ansible.model.Playbook;
|
||||||
|
@ -62,7 +65,7 @@ public class AnsibleWorker {
|
||||||
|
|
||||||
public void removeWorkStructure() {
|
public void removeWorkStructure() {
|
||||||
// remove the working dir
|
// remove the working dir
|
||||||
// this.getWorkdir().delete();
|
//this.getWorkdir().delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getPlaybookFile() {
|
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
|
// 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -202,8 +202,10 @@ public class AnsibleBridge {
|
||||||
FileOutputStream fos = new FileOutputStream(n);
|
FileOutputStream fos = new FileOutputStream(n);
|
||||||
PrintStream ps = new PrintStream(fos);
|
PrintStream ps = new PrintStream(fos);
|
||||||
System.setOut(ps);
|
System.setOut(ps);
|
||||||
|
System.setErr(ps);
|
||||||
worker.apply();
|
worker.apply();
|
||||||
System.setOut(console);
|
System.setOut(console);
|
||||||
|
System.setErr(console);
|
||||||
worker.apply();
|
worker.apply();
|
||||||
System.out.println("Log stored to to " + n.getAbsolutePath());
|
System.out.println("Log stored to to " + n.getAbsolutePath());
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
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.dataanalysis.dataminer.poolmanager.datamodel.Host;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
|
@ -27,7 +29,8 @@ public class ISClient {
|
||||||
if (!remote) {
|
if (!remote) {
|
||||||
Collection<Host> out = new Vector<>();
|
Collection<Host> out = new Vector<>();
|
||||||
Host h = new Host();
|
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);
|
out.add(h);
|
||||||
return out;
|
return out;
|
||||||
} else {
|
} 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());
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.QueryParam;
|
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.datamodel.Algorithm;
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.service.DataminerPoolManager;
|
import org.gcube.dataanalysis.dataminer.poolmanager.service.DataminerPoolManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -57,6 +58,7 @@ public class RestPoolManager implements PoolManager {
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException, InterruptedException {
|
public static void main(String[] args) throws IOException, InterruptedException {
|
||||||
RestPoolManager a = new RestPoolManager();
|
RestPoolManager a = new RestPoolManager();
|
||||||
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||||
a.addAlgorithmToVRE("http://data.d4science.org/R0FqV2lNOW1jMkxuUEIrWXY4aUhvSENHSmVMQks4NjdHbWJQNStIS0N6Yz0", "/gcube/devNext/NextNext");
|
a.addAlgorithmToVRE("http://data.d4science.org/R0FqV2lNOW1jMkxuUEIrWXY4aUhvSENHSmVMQks4NjdHbWJQNStIS0N6Yz0", "/gcube/devNext/NextNext");
|
||||||
//System.out.println(a.getLogById("dadcb059-69e5-48c3-aa58-3b290ae0419d"));
|
//System.out.println(a.getLogById("dadcb059-69e5-48c3-aa58-3b290ae0419d"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class DataminerPoolManager implements PoolManager {
|
||||||
};
|
};
|
||||||
new Thread(r).start();
|
new Thread(r).start();
|
||||||
//this line will execute immediately, not waiting for your task to complete
|
//this line will execute immediately, not waiting for your task to complete
|
||||||
System.out.println(uuid);
|
System.out.println(uuid);
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,6 @@ public class DataminerPoolManager implements PoolManager {
|
||||||
|
|
||||||
// apply the changes
|
// apply the changes
|
||||||
AnsibleBridge a = new AnsibleBridge();
|
AnsibleBridge a = new AnsibleBridge();
|
||||||
|
|
||||||
return a.applyAlgorithmSetToCluster(algorithms, cluster,uuid).getWorkerId();
|
return a.applyAlgorithmSetToCluster(algorithms, cluster,uuid).getWorkerId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue