2017-03-03 19:10:02 +01:00
|
|
|
package org.gcube.dataanalysis.dataminer.poolmanager.ansiblebridge.template;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.ansible.model.Role;
|
2017-04-26 17:39:24 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.ansiblebridge.AnsibleBridge;
|
2017-03-03 19:10:02 +01:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.ansiblebridge.AnsibleSerializeHelper;
|
|
|
|
|
|
|
|
public class StaticRoleManager {
|
|
|
|
|
|
|
|
|
2017-04-26 17:39:24 +02:00
|
|
|
public StaticRoleManager() {
|
|
|
|
|
2017-03-03 19:10:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getRoot() {
|
2017-04-26 17:39:24 +02:00
|
|
|
String input = AnsibleBridge.class.getClassLoader().getResource("static").getPath();
|
|
|
|
return input;
|
2017-03-03 19:10:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Collection<Role> getStaticRoles() {
|
|
|
|
Collection<Role> out = new Vector<>();
|
|
|
|
for(File f: new File(this.getRoot()).listFiles()) {
|
2017-04-26 17:39:24 +02:00
|
|
|
try {
|
2017-03-03 19:10:02 +01:00
|
|
|
out.add(AnsibleSerializeHelper.deserializeRoleFromFilesystem(f));
|
|
|
|
} catch(IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|