This commit is contained in:
Nunzio Andrea Galante 2017-02-21 09:59:25 +00:00
parent 3b76c592e3
commit 1c77915423
4 changed files with 30 additions and 6 deletions

View File

@ -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;
***REMOVED*** ***REMOVED***
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 ***REMOVED***
public void removeWorkStructure() ***REMOVED*** public void removeWorkStructure() ***REMOVED***
***REMOVED*** remove the working dir ***REMOVED*** remove the working dir
***REMOVED*** this.getWorkdir().delete(); ***REMOVED***this.getWorkdir().delete();
***REMOVED*** ***REMOVED***
public File getPlaybookFile() ***REMOVED*** public File getPlaybookFile() ***REMOVED***
@ -91,9 +94,21 @@ public class AnsibleWorker ***REMOVED***
public void apply() ***REMOVED*** public void apply() throws IOException ***REMOVED***
***REMOVED*** TODO execute the playbook and return output ***REMOVED*** TODO execute the playbook and return output
System.out.println("TODO: execute: ansible-playbook -v -i " + this.getInventoryFile().getName() + " " + this.getPlaybookFile().getName()); try ***REMOVED***
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) ***REMOVED***
System.out.println(line);
***REMOVED***
***REMOVED*** catch (IOException e) ***REMOVED***
e.printStackTrace();
***REMOVED***
***REMOVED***System.out.println("TODO: execute: ansible-playbook -v -i " + this.getInventoryFile().getName() + " " + this.getPlaybookFile().getName());
***REMOVED*** ***REMOVED***
/** /**

View File

@ -202,8 +202,10 @@ public class AnsibleBridge ***REMOVED***
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());

View File

@ -8,6 +8,8 @@ import java.util.Collection;
import java.util.Vector; import java.util.Vector;
import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint;
***REMOVED***
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 ***REMOVED***
if (!remote) ***REMOVED*** if (!remote) ***REMOVED***
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"); ***REMOVED***h.setName("bb-dataminer.res.eng.it");
h.setName("vm123.ui.savba.sk");
out.add(h); out.add(h);
return out; return out;
***REMOVED*** else ***REMOVED*** ***REMOVED*** else ***REMOVED***
@ -51,4 +54,9 @@ public class ISClient ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** public static void main(String[] args) ***REMOVED***
***REMOVED*** ISClient a = new ISClient();
***REMOVED*** ScopeProvider.instance.set("/gcube/devNext/NextNext");
***REMOVED*** System.out.println(a.listDataminersInVRE());
***REMOVED******REMOVED***
***REMOVED*** ***REMOVED***

View File

@ -207,7 +207,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED***; ***REMOVED***;
new Thread(r).start(); new Thread(r).start();
***REMOVED***this line will execute immediately, not waiting for your task to complete ***REMOVED***this line will execute immediately, not waiting for your task to complete
System.out.println(uuid); System.out.println(uuid);
return uuid; return uuid;
***REMOVED*** ***REMOVED***
@ -235,7 +235,6 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED*** apply the changes ***REMOVED*** 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();
***REMOVED*** ***REMOVED***