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.NoSuchElementException;
|
|
|
|
|
|
|
|
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 CustomRoleManager {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getRoot() {
|
2017-04-26 17:39:24 +02:00
|
|
|
String input = AnsibleBridge.class.getClassLoader().getResource("custom").getPath();
|
|
|
|
|
|
|
|
return input;
|
2017-03-03 19:10:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Role getRole(String roleName) throws NoSuchElementException {
|
|
|
|
File f = new File(this.getRoot(), roleName);
|
|
|
|
try {
|
|
|
|
return AnsibleSerializeHelper.deserializeRoleFromFilesystem(f);
|
|
|
|
} catch (IOException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
throw new NoSuchElementException("unable to find " + roleName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|