|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.location.basic.AbstractLocation
brooklyn.location.basic.SshMachineLocation
public class SshMachineLocation extends AbstractLocation
Operations on a machine that is accessible via ssh.
We expose two ways of running scripts. One (execCommands) passes lines to bash, that is lightweight but fragile. Another (execScript) creates a script on the remote machine, more portable but heavier.
Additionally there are routines to copyTo, copyFrom; and installTo (which tries a curl, and falls back to copyTo in event the source is accessible by the caller only).
Nested Class Summary | |
---|---|
protected interface |
SshMachineLocation.ExecRunner
|
Field Summary | |
---|---|
static Logger |
LOG
|
static java.util.Collection |
NON_SSH_PROPS
|
static java.lang.String |
SSHCONFIG_PREFIX
any property that should be passed as ssh config (connection-time) can be prefixed with this and . and will be passed through (with the prefix removed), e.g. |
static java.util.Collection |
SSH_PROPS
properties which are passed to ssh |
static Logger |
logSsh
|
protected boolean |
previouslyConnected
|
Fields inherited from class AbstractLocation | |
---|---|
LOG, hostGeoInfo, leftoverProperties, name |
Constructor Summary | |
SshMachineLocation()
|
|
SshMachineLocation(java.util.Map properties)
|
Method Summary | |
---|---|
void
|
acquireMutex(java.lang.String mutexId, java.lang.String description)
|
void
|
configure()
|
void
|
configure(java.util.Map properties)
|
protected SshTool
|
connectSsh()
|
protected SshTool
|
connectSsh(java.util.Map props)
|
int
|
copyFrom(java.lang.String remote, java.lang.String local)
|
int
|
copyFrom(java.util.Map props, java.lang.String remote, java.lang.String local)
|
int
|
copyTo(java.io.File src, java.io.File destination)
|
int
|
copyTo(java.util.Map props, java.io.File src, java.io.File destination)
|
int
|
copyTo(java.io.File src, java.lang.String destination)
|
int
|
copyTo(java.util.Map props, java.io.File src, java.lang.String destination)
|
int
|
copyTo(java.io.Reader src, java.lang.String destination)
|
int
|
copyTo(java.util.Map props, java.io.Reader src, java.lang.String destination)
|
int
|
copyTo(java.io.InputStream src, java.lang.String destination)
|
int
|
copyTo(java.util.Map props, java.io.InputStream src, java.lang.String destination)
|
int
|
copyTo(java.io.InputStream src, long filesize, java.lang.String destination)
|
int
|
copyTo(java.util.Map props, java.io.InputStream src, long filesize, java.lang.String destination)
|
int
|
exec(java.util.List commands)
Convenience for running commands using ssh {@literal exec} mode. |
int
|
exec(java.util.Map props, java.util.List commands)
|
int
|
exec(java.util.List commands, java.util.Map env)
|
int
|
exec(java.util.Map props, java.util.List commands, java.util.Map env)
|
int
|
execCommands(java.lang.String summaryForLogging, java.util.List commands)
executes a set of commands, directly on the target machine (no wrapping in script). |
int
|
execCommands(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands)
|
int
|
execCommands(java.lang.String summaryForLogging, java.util.List commands, java.util.Map env)
|
int
|
execCommands(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands, java.util.Map env)
|
int
|
execScript(java.lang.String summaryForLogging, java.util.List commands)
executes a set of commands, wrapped as a script sent to the remote machine. |
int
|
execScript(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands)
|
int
|
execScript(java.lang.String summaryForLogging, java.util.List commands, java.util.Map env)
|
int
|
execScript(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands, java.util.Map env)
|
protected int
|
execWithLogging(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands, java.util.Map env, groovy.lang.Closure execCommand)
|
protected int
|
execWithLogging(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands, java.util.Map env, SshMachineLocation.ExecRunner execCommand)
|
java.net.InetAddress
|
getAddress()
|
java.util.Map
|
getConfig()
|
OsDetails
|
getOsDetails()
|
java.lang.String
|
getUser()
|
boolean
|
hasMutex(java.lang.String mutexId)
|
int
|
installTo(ResourceUtils loader, java.lang.String url, java.lang.String destination)
installs the given URL at the indicated destination. |
boolean
|
isSshable()
|
protected WithMutexes
|
newMutexSupport()
|
int
|
obtainPort(PortRange range)
|
boolean
|
obtainSpecificPort(int portNumber)
@see #obtainPort(PortRange) |
void
|
releaseMutex(java.lang.String mutexId)
|
void
|
releasePort(int portNumber)
|
int
|
run(java.lang.String command)
|
int
|
run(java.util.Map props, java.lang.String command)
|
int
|
run(java.lang.String command, java.util.Map env)
|
int
|
run(java.util.Map props, java.lang.String command, java.util.Map env)
|
int
|
run(java.util.List commands)
|
int
|
run(java.util.Map props, java.util.List commands)
|
int
|
run(java.util.List commands, java.util.Map env)
|
int
|
run(java.util.Map props, java.util.List commands, java.util.Map env)
|
java.lang.String
|
toString()
|
boolean
|
tryAcquireMutex(java.lang.String mutexId, java.lang.String description)
|
Methods inherited from class AbstractLocation | |
---|---|
addChildLocation, configure, configure, containsLocation, equals, findLocationProperty, getChildLocations, getHostGeoInfo, getId, getLocationProperty, getName, getParentLocation, hasLocationProperty, hashCode, removeChildLocation, setHostGeoInfo, setParentLocation, string, toString |
Field Detail |
---|
public static final Logger LOG
public static final java.util.Collection NON_SSH_PROPS
public static final java.lang.String SSHCONFIG_PREFIX
public static final java.util.Collection SSH_PROPS
public static final Logger logSsh
protected boolean previouslyConnected
Constructor Detail |
---|
public SshMachineLocation()
public SshMachineLocation(java.util.Map properties)
Method Detail |
---|
@Override public void acquireMutex(java.lang.String mutexId, java.lang.String description)
public void configure()
public void configure(java.util.Map properties)
protected SshTool connectSsh()
protected SshTool connectSsh(java.util.Map props)
public int copyFrom(java.lang.String remote, java.lang.String local)
public int copyFrom(java.util.Map props, java.lang.String remote, java.lang.String local)
public int copyTo(java.io.File src, java.io.File destination)
public int copyTo(java.util.Map props, java.io.File src, java.io.File destination)
public int copyTo(java.io.File src, java.lang.String destination)
public int copyTo(java.util.Map props, java.io.File src, java.lang.String destination)
public int copyTo(java.io.Reader src, java.lang.String destination)
public int copyTo(java.util.Map props, java.io.Reader src, java.lang.String destination)
public int copyTo(java.io.InputStream src, java.lang.String destination)
public int copyTo(java.util.Map props, java.io.InputStream src, java.lang.String destination)
public int copyTo(java.io.InputStream src, long filesize, java.lang.String destination)
public int copyTo(java.util.Map props, java.io.InputStream src, long filesize, java.lang.String destination)
public int exec(java.util.List commands)
public int exec(java.util.Map props, java.util.List commands)
public int exec(java.util.List commands, java.util.Map env)
public int exec(java.util.Map props, java.util.List commands, java.util.Map env)
public int execCommands(java.lang.String summaryForLogging, java.util.List commands)
Stdout and stderr will be logged automatically to brooklyn.SSH logger, unless the flags 'noStdoutLogging' and 'noStderrLogging' are set. To set a logging prefix, use the flag 'logPrefix'.
Currently runs the commands in an interactive/login shell by passing each as a line to bash. To terminate early, use:
foo || exit 1It may be desirable instead, in some situations, to wrap as:
{ line1 ; } && { line2 ; } ...and run as a single command (possibly not as an interacitve/login shell) causing the script to exit on the first command which fails.
Currently this has to be done by the caller. (If desired we can add a flag exitIfAnyNonZero to support this mode, and/or commandPrepend and commandAppend similar to (currently supported in SshjTool) separator.)
public int execCommands(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands)
public int execCommands(java.lang.String summaryForLogging, java.util.List commands, java.util.Map env)
public int execCommands(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands, java.util.Map env)
public int execScript(java.lang.String summaryForLogging, java.util.List commands)
Stdout and stderr will be logged automatically to brooklyn.SSH logger, unless the flags 'noStdoutLogging' and 'noStderrLogging' are set. To set a logging prefix, use the flag 'logPrefix'.
public int execScript(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands)
public int execScript(java.lang.String summaryForLogging, java.util.List commands, java.util.Map env)
public int execScript(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands, java.util.Map env)
protected int execWithLogging(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands, java.util.Map env, groovy.lang.Closure execCommand)
protected int execWithLogging(java.util.Map props, java.lang.String summaryForLogging, java.util.List commands, java.util.Map env, SshMachineLocation.ExecRunner execCommand)
public java.net.InetAddress getAddress()
public java.util.Map getConfig()
@Override public OsDetails getOsDetails()
public java.lang.String getUser()
@Override public boolean hasMutex(java.lang.String mutexId)
public int installTo(ResourceUtils loader, java.lang.String url, java.lang.String destination)
accepts either a path (terminated with /) or filename for the destination.
public boolean isSshable()
protected WithMutexes newMutexSupport()
public int obtainPort(PortRange range)
public boolean obtainSpecificPort(int portNumber)
@Override public void releaseMutex(java.lang.String mutexId)
public void releasePort(int portNumber)
public int run(java.lang.String command)
public int run(java.util.Map props, java.lang.String command)
public int run(java.lang.String command, java.util.Map env)
public int run(java.util.Map props, java.lang.String command, java.util.Map env)
public int run(java.util.List commands)
public int run(java.util.Map props, java.util.List commands)
public int run(java.util.List commands, java.util.Map env)
public int run(java.util.Map props, java.util.List commands, java.util.Map env)
@Override public java.lang.String toString()
@Override public boolean tryAcquireMutex(java.lang.String mutexId, java.lang.String description)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.