git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@144015 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1c77915423
commit
badf193963
|
@ -3,8 +3,10 @@ package org.gcube.dataanalysis.dataminer.poolmanager.ansible;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.PrintStream;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -65,7 +67,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();
|
this.getWorkdir().delete();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
public File getPlaybookFile() ***REMOVED***
|
public File getPlaybookFile() ***REMOVED***
|
||||||
|
@ -96,21 +98,32 @@ public class AnsibleWorker ***REMOVED***
|
||||||
|
|
||||||
public void apply() throws IOException ***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(this.getWorkdir());
|
||||||
try ***REMOVED***
|
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().getAbsolutePath() + " " + this.getPlaybookFile().getAbsolutePath());
|
||||||
Process p = Runtime.getRuntime().exec("ansible-playbook -v -i " + this.getInventoryFile().getName() + " " + this.getPlaybookFile().getName());
|
|
||||||
BufferedReader in = new BufferedReader(
|
inheritIO(p.getInputStream(), System.out);
|
||||||
new InputStreamReader(p.getInputStream()));
|
inheritIO(p.getErrorStream(), System.err);
|
||||||
String line = null;
|
|
||||||
while ((line = in.readLine()) != null) ***REMOVED***
|
|
||||||
System.out.println(line);
|
|
||||||
***REMOVED***
|
|
||||||
***REMOVED*** catch (IOException e) ***REMOVED***
|
***REMOVED*** catch (IOException e) ***REMOVED***
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***System.out.println("TODO: execute: ansible-playbook -v -i " + this.getInventoryFile().getName() + " " + this.getPlaybookFile().getName());
|
***REMOVED***System.out.println("TODO: execute: ansible-playbook -v -i " + this.getInventoryFile().getName() + " " + this.getPlaybookFile().getName());
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static void inheritIO(final InputStream src, final PrintStream dest) ***REMOVED***
|
||||||
|
new Thread(new Runnable() ***REMOVED***
|
||||||
|
public void run() ***REMOVED***
|
||||||
|
Scanner sc = new Scanner(src);
|
||||||
|
while (sc.hasNextLine()) ***REMOVED***
|
||||||
|
dest.println(sc.nextLine());
|
||||||
|
***REMOVED***
|
||||||
|
***REMOVED***
|
||||||
|
***REMOVED***).start();
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the worker:
|
* Destroy the worker:
|
||||||
* - remove the working dir
|
* - remove the working dir
|
||||||
|
|
|
@ -9,6 +9,8 @@ public class Playbook ***REMOVED***
|
||||||
|
|
||||||
private List<String> roles;
|
private List<String> roles;
|
||||||
|
|
||||||
|
private String remote_user;
|
||||||
|
|
||||||
public Playbook() ***REMOVED***
|
public Playbook() ***REMOVED***
|
||||||
this.roles = new Vector<>();
|
this.roles = new Vector<>();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
@ -29,4 +31,20 @@ public class Playbook ***REMOVED***
|
||||||
return new Vector<>(roles);
|
return new Vector<>(roles);
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
public String getRemote_user() ***REMOVED***
|
||||||
|
return remote_user;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
public void setRemote_user(String remote_user) ***REMOVED***
|
||||||
|
this.remote_user = remote_user;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
public void setHostGroupName(String hostGroupName) ***REMOVED***
|
||||||
|
this.hostGroupName = hostGroupName;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
public void setRoles(List<String> roles) ***REMOVED***
|
||||||
|
this.roles = roles;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -184,6 +184,7 @@ public class AnsibleBridge ***REMOVED***
|
||||||
|
|
||||||
***REMOVED*** generate the playbook
|
***REMOVED*** generate the playbook
|
||||||
Playbook playbook = new Playbook();
|
Playbook playbook = new Playbook();
|
||||||
|
playbook.setRemote_user("root");
|
||||||
playbook.applyTo("universe");
|
playbook.applyTo("universe");
|
||||||
for(Role r:algoRoles) ***REMOVED***
|
for(Role r:algoRoles) ***REMOVED***
|
||||||
***REMOVED*** add only 'add' roles
|
***REMOVED*** add only 'add' roles
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class AnsibleSerializeHelper ***REMOVED***
|
||||||
|
|
||||||
public static void serialize(Playbook playbook, File playbookFile) throws IOException ***REMOVED***
|
public static void serialize(Playbook playbook, File playbookFile) throws IOException ***REMOVED***
|
||||||
String out = "- hosts: " + playbook.getHostGroupName() + "\n";
|
String out = "- hosts: " + playbook.getHostGroupName() + "\n";
|
||||||
out += " remote_user: dpm\n";
|
out += " remote_user: "+playbook.getRemote_user()+"\n";
|
||||||
out+=" roles:\n";
|
out+=" roles:\n";
|
||||||
for(String r:playbook.getRoles()) ***REMOVED***
|
for(String r:playbook.getRoles()) ***REMOVED***
|
||||||
out+=" - " + r+"\n";
|
out+=" - " + r+"\n";
|
||||||
|
|
|
@ -37,8 +37,11 @@ public class ISClient ***REMOVED***
|
||||||
|
|
||||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||||
|
|
||||||
query.addCondition("$resource/Profile/Category/text() eq 'DataAnalysis'")
|
***REMOVED***old version
|
||||||
.addCondition("$resource/Profile/Name/text() eq 'DataMiner'");
|
***REMOVED***query.addCondition("$resource/Profile/Category/text() eq 'DataAnalysis'")
|
||||||
|
***REMOVED***.addCondition("$resource/Profile/Name/text() eq 'DataMiner'");
|
||||||
|
|
||||||
|
query.addCondition("$resource/Profile/Platform/Name/text() eq 'DataMiner'");
|
||||||
|
|
||||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||||
|
|
||||||
|
@ -54,9 +57,9 @@ public class ISClient ***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
***REMOVED*** public static void main(String[] args) ***REMOVED***
|
public static void main(String[] args) ***REMOVED***
|
||||||
***REMOVED*** ISClient a = new ISClient();
|
ISClient a = new ISClient();
|
||||||
***REMOVED*** ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||||
***REMOVED*** System.out.println(a.listDataminersInVRE());
|
System.out.println(a.listDataminersInVRE());
|
||||||
***REMOVED******REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -193,7 +193,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
|
||||||
algoSet.addAlgorithm(algorithm);
|
algoSet.addAlgorithm(algorithm);
|
||||||
final String uuid = UUID.randomUUID().toString();
|
final String uuid = UUID.randomUUID().toString();
|
||||||
|
|
||||||
Runnable r = new Runnable() ***REMOVED***
|
new Thread(new Runnable() ***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
public void run() ***REMOVED***
|
public void run() ***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
@ -204,8 +204,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***;
|
***REMOVED***).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;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.net.ProxySelector;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.AlgorithmSet;
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.AlgorithmSet;
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
|
||||||
|
***REMOVED***
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.PropertiesBasedProxySelector;
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.PropertiesBasedProxySelector;
|
||||||
|
|
||||||
public class DataminerPoolManagerTest ***REMOVED***
|
public class DataminerPoolManagerTest ***REMOVED***
|
||||||
|
@ -160,58 +161,58 @@ public class DataminerPoolManagerTest ***REMOVED***
|
||||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||||
|
|
||||||
ProxySelector.setDefault(new PropertiesBasedProxySelector("/home/ngalante/.proxy-settings"));
|
ProxySelector.setDefault(new PropertiesBasedProxySelector("/home/ngalante/.proxy-settings"));
|
||||||
|
***REMOVED***
|
||||||
***REMOVED*** create the algorithm (download it, etc etc)
|
***REMOVED*** ***REMOVED*** create the algorithm (download it, etc etc)
|
||||||
Algorithm algorithm = new Algorithm();
|
***REMOVED*** Algorithm algorithm = new Algorithm();
|
||||||
algorithm.setName("ichtyop");
|
***REMOVED*** algorithm.setName("ichtyop");
|
||||||
algorithm.setClazz("org.gcube...");
|
***REMOVED*** algorithm.setClazz("org.gcube...");
|
||||||
algorithm.setDescription("some description");
|
***REMOVED*** algorithm.setDescription("some description");
|
||||||
|
***REMOVED***
|
||||||
Dependency d = new Dependency();
|
***REMOVED*** Dependency d = new Dependency();
|
||||||
d.setName("libpng");
|
***REMOVED*** d.setName("libpng");
|
||||||
d.setType("os");
|
***REMOVED*** d.setType("os");
|
||||||
algorithm.addDependency(d);
|
***REMOVED*** algorithm.addDependency(d);
|
||||||
|
***REMOVED***
|
||||||
d = new Dependency();
|
***REMOVED*** d = new Dependency();
|
||||||
d.setName("some-r-package");
|
***REMOVED*** d.setName("some-r-package");
|
||||||
d.setType("cran");
|
***REMOVED*** d.setType("cran");
|
||||||
algorithm.addDependency(d);
|
***REMOVED*** algorithm.addDependency(d);
|
||||||
|
***REMOVED***
|
||||||
d = new Dependency();
|
***REMOVED*** d = new Dependency();
|
||||||
d.setName("some-other-r-package");
|
***REMOVED*** d.setName("some-other-r-package");
|
||||||
d.setType("cran");
|
***REMOVED*** d.setType("cran");
|
||||||
algorithm.addDependency(d);
|
***REMOVED*** algorithm.addDependency(d);
|
||||||
|
***REMOVED***
|
||||||
d = new Dependency();
|
***REMOVED*** d = new Dependency();
|
||||||
d.setName("voodoo");
|
***REMOVED*** d.setName("voodoo");
|
||||||
d.setType("custom");
|
***REMOVED*** d.setType("custom");
|
||||||
algorithm.addDependency(d);
|
***REMOVED*** algorithm.addDependency(d);
|
||||||
|
***REMOVED***
|
||||||
***REMOVED*** create the algorithm (download it, etc etc)
|
***REMOVED*** ***REMOVED*** create the algorithm (download it, etc etc)
|
||||||
Algorithm ewe = new Algorithm();
|
***REMOVED*** Algorithm ewe = new Algorithm();
|
||||||
ewe.setName("ewe");
|
***REMOVED*** ewe.setName("ewe");
|
||||||
|
***REMOVED***
|
||||||
d = new Dependency();
|
***REMOVED*** d = new Dependency();
|
||||||
d.setName("voodoo");
|
***REMOVED*** d.setName("voodoo");
|
||||||
d.setType("custom");
|
***REMOVED*** d.setType("custom");
|
||||||
ewe.addDependency(d);
|
***REMOVED*** ewe.addDependency(d);
|
||||||
|
|
||||||
AlgorithmSet algorithms = new AlgorithmSet();
|
AlgorithmSet algorithms = new AlgorithmSet();
|
||||||
algorithms.setName("dummy-set");
|
algorithms.setName("dummy-set");
|
||||||
|
|
||||||
algorithms.addAlgorithm(algorithm);
|
***REMOVED*** algorithms.addAlgorithm(algorithm);
|
||||||
algorithms.addAlgorithm(ewe);
|
***REMOVED*** algorithms.addAlgorithm(ewe);
|
||||||
|
|
||||||
Algorithm ensemble = new Algorithm();
|
Algorithm ensemble = new Algorithm();
|
||||||
ensemble.setName("ensemble");
|
ensemble.setName("ensemble");
|
||||||
|
|
||||||
d = new Dependency();
|
Dependency d = new Dependency();
|
||||||
d.setName("libpng");
|
d.setName("libpng3");
|
||||||
d.setType("os");
|
d.setType("os");
|
||||||
ensemble.addDependency(d);
|
ensemble.addDependency(d);
|
||||||
algorithms.addAlgorithm(ensemble);
|
algorithms.addAlgorithm(ensemble);
|
||||||
|
|
||||||
***REMOVED***new DataminerPoolManager().addAlgorithmsToVRE(algorithms, "/gcube/devNext/NextNext");
|
new DataminerPoolManager().addAlgorithmsToVRE(algorithms, "/gcube/devNext/NextNext", "test");
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue