scripting
Class ScriptCaller

java.lang.Object
  extended by scripting.ScriptCaller

public class ScriptCaller
extends java.lang.Object

Class for calling the bash scripts from java

Author:
Leo Bosnjak

Nested Class Summary
(package private)  class ScriptCaller.CopyThread
          inner class to copy files to node & bootstrap node
 
Field Summary
private  boolean batchMode
           
private static java.lang.String BOOTSTRAP_CMD_LINUX
           
private static java.lang.String BOOTSTRAP_CMD_WIN
           
private static java.lang.String bootstrapCmd
           
private static java.lang.String COPYDIR_CMD_LINUX
           
private static java.lang.String COPYDIR_CMD_WIN
           
private static java.lang.String CopyDirCmd
           
private static java.lang.String EXECUTE_CMD_LINUX
           
private static java.lang.String EXECUTE_CMD_WIN
           
private static java.lang.String executeCmd
           
private static java.lang.String GETDIR_CMD_LINUX
           
private static java.lang.String GETDIR_CMD_WIN
           
private static java.lang.String getDirCmd
           
private static boolean linuxOS
           
private static java.lang.String MOUNT_CMD
           
 
Constructor Summary
ScriptCaller()
           
 
Method Summary
 boolean bootstrapNodes(PlanetLabMgr planetLabApi, java.lang.String[] hostnames)
          Bootstraps the given nodes: cleans up running daemons starts the needed daemons
 void copyDir(PlanetLabMgr planetLabApi, java.lang.String hostname, java.lang.String localDir, java.lang.String remoteDir, boolean setupNode)
          copies a local dir to the remote node via a shell script that uses ssh/rsync
 boolean copyDirToNodes(PlanetLabMgr planetLabApi, java.lang.String[] hostnames, java.lang.String localDir, java.lang.String remoteDir, boolean setupNode)
          copies a local dir to the remote nodes via a shell script that uses ssh/rsync
 boolean executeCommandOnNodes(PlanetLabMgr planetLabApi, java.lang.String[] hostnames, java.lang.String command)
          Executes a given command on the nodes
 boolean getDirFromNodes(PlanetLabMgr planetLabApi, java.lang.String[] hostnames, java.lang.String remoteDir, java.lang.String localDir)
          Transfers the remote directory from each of the nodes and saves it to the local directory This is done via a shell script that uses scp.
 boolean isBatchMode()
           
static boolean isLinuxOS()
          Tells whether the ScriptCaller thinks that we're running on a linux OS.
 void mountNodes(PlanetLabMgr planetLabApi, java.lang.String[] hostnames, java.lang.String[] localDirs, java.lang.String remoteDir, boolean mount)
          mounts the nodes in local filesys via a shell script that uses sshfs
 void setBatchMode(boolean batchMode)
           
static void setLinuxOS(boolean linuxOS)
          Tells the ScriptCaller whether we're running on a linux OS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYDIR_CMD_LINUX

private static final java.lang.String COPYDIR_CMD_LINUX
See Also:
Constant Field Values

COPYDIR_CMD_WIN

private static final java.lang.String COPYDIR_CMD_WIN
See Also:
Constant Field Values

GETDIR_CMD_LINUX

private static final java.lang.String GETDIR_CMD_LINUX
See Also:
Constant Field Values

GETDIR_CMD_WIN

private static final java.lang.String GETDIR_CMD_WIN
See Also:
Constant Field Values

BOOTSTRAP_CMD_LINUX

private static final java.lang.String BOOTSTRAP_CMD_LINUX
See Also:
Constant Field Values

BOOTSTRAP_CMD_WIN

private static final java.lang.String BOOTSTRAP_CMD_WIN
See Also:
Constant Field Values

EXECUTE_CMD_LINUX

private static final java.lang.String EXECUTE_CMD_LINUX
See Also:
Constant Field Values

EXECUTE_CMD_WIN

private static final java.lang.String EXECUTE_CMD_WIN
See Also:
Constant Field Values

MOUNT_CMD

private static final java.lang.String MOUNT_CMD
See Also:
Constant Field Values

batchMode

private boolean batchMode

CopyDirCmd

private static java.lang.String CopyDirCmd

bootstrapCmd

private static java.lang.String bootstrapCmd

getDirCmd

private static java.lang.String getDirCmd

executeCmd

private static java.lang.String executeCmd

linuxOS

private static boolean linuxOS
Constructor Detail

ScriptCaller

public ScriptCaller()
Method Detail

copyDir

public void copyDir(PlanetLabMgr planetLabApi,
                    java.lang.String hostname,
                    java.lang.String localDir,
                    java.lang.String remoteDir,
                    boolean setupNode)
copies a local dir to the remote node via a shell script that uses ssh/rsync


copyDirToNodes

public boolean copyDirToNodes(PlanetLabMgr planetLabApi,
                              java.lang.String[] hostnames,
                              java.lang.String localDir,
                              java.lang.String remoteDir,
                              boolean setupNode)
copies a local dir to the remote nodes via a shell script that uses ssh/rsync


getDirFromNodes

public boolean getDirFromNodes(PlanetLabMgr planetLabApi,
                               java.lang.String[] hostnames,
                               java.lang.String remoteDir,
                               java.lang.String localDir)
Transfers the remote directory from each of the nodes and saves it to the local directory This is done via a shell script that uses scp.

Parameters:
planetLabApi -
remoteDir - - the remote directory which is located at each node
localDir - - the local directory which is used as destination for the remote directories of the nodes. A subdirectory named like the hostname of each node will be created to save the remote dir of the node.
hostnames - - the hostnames of the nodes from which the directory will be copied to your pc
Returns:
true if successful

mountNodes

public void mountNodes(PlanetLabMgr planetLabApi,
                       java.lang.String[] hostnames,
                       java.lang.String[] localDirs,
                       java.lang.String remoteDir,
                       boolean mount)
mounts the nodes in local filesys via a shell script that uses sshfs


bootstrapNodes

public boolean bootstrapNodes(PlanetLabMgr planetLabApi,
                              java.lang.String[] hostnames)
Bootstraps the given nodes: cleans up running daemons starts the needed daemons


executeCommandOnNodes

public boolean executeCommandOnNodes(PlanetLabMgr planetLabApi,
                                     java.lang.String[] hostnames,
                                     java.lang.String command)
Executes a given command on the nodes


isBatchMode

public boolean isBatchMode()
Returns:
the batchMode

setBatchMode

public void setBatchMode(boolean batchMode)
Parameters:
batchMode - the batchMode to set

isLinuxOS

public static boolean isLinuxOS()
Tells whether the ScriptCaller thinks that we're running on a linux OS. The batch commands which will be called depend on the OS.

Returns:
true if the member variable linuxOS is set

setLinuxOS

public static void setLinuxOS(boolean linuxOS)
Tells the ScriptCaller whether we're running on a linux OS. The batch commands which will be called depend on the OS.