Brooklyn

brooklyn.entity.basic.lifecycle
[Java] Class CommonCommands

java.lang.Object
  brooklyn.entity.basic.lifecycle.CommonCommands

public class CommonCommands

Field Summary
static java.lang.String INSTALL_CURL

static java.lang.String INSTALL_TAR

static java.lang.String INSTALL_WGET

 
Method Summary
static java.lang.String alternatives(java.util.Collection commands, java.lang.String failure)

Returns a sequence of alternative commands that runs until one of the commands succeeds

static java.lang.String chain(java.util.Collection commands)

Returns a sequence of chained commands that runs until one of them fails

static java.util.List downloadUrlAs(java.util.Map flags, java.lang.String url, java.lang.String entityVersionPath, java.lang.String pathlessFilenameToSaveAs)

Returns command for downloading from a url and saving to a file; currently using curl.

static java.util.List downloadUrlAs(java.lang.String url, java.lang.String entityVersionPath, java.lang.String pathlessFilenameToSaveAs)

static java.lang.String exists(java.lang.String executable, java.lang.String... commands)

Returns a command that runs only if the specified executable is in the path.

static java.lang.String file(java.lang.String path, java.lang.String command)

Returns a command that runs only if the specified executable is in the path

static java.lang.String formatIfNotNull(java.lang.String pattern, java.lang.Object arg)

returns the pattern formatted with the given arg if the arg is not null, otherwise returns null

static java.lang.String installExecutable(java.util.Map flags, java.lang.String executable)

Returns a string for checking whether the given executable is available, and installing it if necessary.

static java.lang.String installExecutable(java.lang.String executable)

static java.lang.String installPackage(java.util.Map flags, java.lang.String packageDefaultName)

Returns a command for installing the given package.

static java.lang.String installPackage(java.lang.String packageDefaultName)

static java.lang.String missing(java.lang.String executable, java.lang.String command)

Returns a command that runs only if the specified executable is NOT in the path

static java.lang.String ok(java.lang.String command)

Returns a command that always exits successfully

static java.lang.String on(java.lang.String osName, java.lang.String command)

Returns a command that runs only 1f the operating system is as specified; Checks /etc/issue for the specified name

static java.lang.String quiet(java.lang.String command)

Returns a command with all output redirected to /dev/null

static java.lang.String sudo(java.lang.String command)

Returns a command for safely running as root, using sudo.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

INSTALL_CURL

public static final java.lang.String INSTALL_CURL


INSTALL_TAR

public static final java.lang.String INSTALL_TAR


INSTALL_WGET

public static final java.lang.String INSTALL_WGET


 
Method Detail

alternatives

public static java.lang.String alternatives(java.util.Collection commands, java.lang.String failure)
Returns a sequence of alternative commands that runs until one of the commands succeeds


chain

public static java.lang.String chain(java.util.Collection commands)
Returns a sequence of chained commands that runs until one of them fails


downloadUrlAs

public static java.util.List downloadUrlAs(java.util.Map flags, java.lang.String url, java.lang.String entityVersionPath, java.lang.String pathlessFilenameToSaveAs)
Returns command for downloading from a url and saving to a file; currently using curl.

Will read from a local repository, if files have been copied there (cp -r /tmp/brooklyn/installs/ ~/.brooklyn/repository/) unless skipLocalrepo is {

literal:
true}.

Ideally use a blobstore staging area.


downloadUrlAs

public static java.util.List downloadUrlAs(java.lang.String url, java.lang.String entityVersionPath, java.lang.String pathlessFilenameToSaveAs)


exists

public static java.lang.String exists(java.lang.String executable, java.lang.String... commands)
Returns a command that runs only if the specified executable is in the path. If command is null, no command runs (and the script component this creates will return true if the executable).


file

public static java.lang.String file(java.lang.String path, java.lang.String command)
Returns a command that runs only if the specified executable is in the path


formatIfNotNull

public static java.lang.String formatIfNotNull(java.lang.String pattern, java.lang.Object arg)
returns the pattern formatted with the given arg if the arg is not null, otherwise returns null


installExecutable

public static java.lang.String installExecutable(java.util.Map flags, java.lang.String executable)
Returns a string for checking whether the given executable is available, and installing it if necessary.

Uses installPackage and accepts the same flags e.g. for apt, yum, rpm.


installExecutable

public static java.lang.String installExecutable(java.lang.String executable)


installPackage

public static java.lang.String installPackage(java.util.Map flags, java.lang.String packageDefaultName)
Returns a command for installing the given package.

Flags can contain common overrides for deb, apt, yum, rpm and port as the package names can be different for each of those:

 installPackage("libssl-devel", yum:"openssl-devel", apt:"openssl libssl-dev zlib1g-dev")
 


installPackage

public static java.lang.String installPackage(java.lang.String packageDefaultName)


missing

public static java.lang.String missing(java.lang.String executable, java.lang.String command)
Returns a command that runs only if the specified executable is NOT in the path


ok

public static java.lang.String ok(java.lang.String command)
Returns a command that always exits successfully


on

public static java.lang.String on(java.lang.String osName, java.lang.String command)
Returns a command that runs only 1f the operating system is as specified; Checks /etc/issue for the specified name


quiet

public static java.lang.String quiet(java.lang.String command)
Returns a command with all output redirected to /dev/null


sudo

public static java.lang.String sudo(java.lang.String command)
Returns a command for safely running as root, using sudo.

Ensuring non-blocking if password not set by using -S which reads from stdin routed to /dev/null and -E passes the parent environment in. If already root, simply runs the command, wrapped in brackets in case it is backgrounded.

The command is not quoted or escaped in any ways. If you are doing privileged redirect you may need to pass e.g. "bash -c 'echo hi > file'".

If null is supplied, it is returned (sometimes used to indicate no command desired).


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.