use of cbit.vcell.server.HtcJobID.BatchSystemType in project vcell by virtualcell.
the class SlurmProxy method creatCommandService.
public static HtcProxy creatCommandService(java.lang.String[] sshHostUserKeyfile) throws IOException {
CommandService commandService = null;
if (sshHostUserKeyfile != null && sshHostUserKeyfile.length == 3) {
ArrayList<String> htcDispatchHostNames = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(sshHostUserKeyfile[0], ", ");
while (st.hasMoreElements()) {
htcDispatchHostNames.add(st.nextToken());
}
// String sshHost = sshHostUserKeyfile[0];
String sshUser = sshHostUserKeyfile[1];
File sshKeyFile = new File(sshHostUserKeyfile[2]);
try {
commandService = new CommandServiceSshNative(htcDispatchHostNames.toArray(new String[0]), sshUser, sshKeyFile);
commandService.command(new String[] { "/usr/bin/env bash -c ls | head -5" });
// lg.trace("SSH Connection test passed with installed keyfile, running ls as user "+sshUser+" on "+sshHost);
} catch (Exception e) {
e.printStackTrace();
try {
commandService = new CommandServiceSshNative(htcDispatchHostNames.toArray(new String[0]), sshUser, sshKeyFile, new File("/root"));
CommandOutput commandOutput = commandService.command(new String[] { "/usr/bin/env bash -c ls | head -5" });
// lg.trace("SSH Connection test passed after installing keyfile, running ls as user "+sshUser+" on "+sshHost);
} catch (Exception e2) {
e.printStackTrace();
throw new RuntimeException("failed to establish an ssh command connection to " + sshHostUserKeyfile[0] + " as user '" + sshUser + "' using key '" + sshKeyFile + "'", e);
}
}
// can't make user directories, they are remote.
AbstractSolver.bMakeUserDirs = false;
} else {
commandService = new CommandServiceLocal();
}
BatchSystemType batchSystemType = BatchSystemType.SLURM;
HtcProxy htcProxy = null;
switch(batchSystemType) {
case SLURM:
{
htcProxy = new SlurmProxy(commandService, PropertyLoader.getRequiredProperty(PropertyLoader.htcUser));
break;
}
default:
{
throw new RuntimeException("unrecognized batch scheduling option :" + batchSystemType);
}
}
return htcProxy;
}
Aggregations