llama dev dv

Execute actions across a bunch of DigitalOcean servers based on their names. Useful for background and sensitivity runs. Executes a shell command on each server using SSH. You can either specify shell scripts to run (in non-interactive mode, as if you were calling “ssh foo@bar ‘my shell command’”) or can provide your own shell command as an argument to the script.

usage: llama dev dv [-h] [-d] [-D] [-p PATTERN] [-l] [-f FORMAT]
                    [-P PRELAUNCH] [-n CONNECTIONS] [-t TIMEOUT]
                    [-r {sum,linecount}]
                    [args [args ...]]

Positional Arguments


Possible choices: destroy, done, eval, forget, init, killall, launch, batch, ls-procs, pull, push, tail

The command to run remotely.


Optional additional arguments to feed to the script specified in cmd. These arguments will be set using set -- arg1 arg2 ... argN before the script specified by cmd is evaluated, effectively making it as if these arguments were passed as $1 through $N to that shell script.

Named Arguments

-d, --descriptions

Print names and descriptions of available commands (see “cmd” above).

Default: False

-D, --defaults

Print default command line flags for each available command.

Default: False

-p, --pattern

An fnmatch-style pattern that droplet names must match. Droplets whose names do not match this pattern will not be included. (default: llama-*)

Default: “llama-*

-l, --local

Run the given command locally instead of on the remote droplet. This is useful for e.g. rsync commands (and anything that is meant to interact with each droplet but which must run on the local machine). These scripts will have the DROPNAME and DROPIP variables set to each droplet’s name and IP address respectively.

Default: False

-f, --format

The format string to use to describe what happened for each command. Should be a typical python format string with “name” referring to the droplet name, “ip” referring to its IP address, “stdout” referring to the standard output of the command, “stderr” the standard error, and “retval” referring to the return code of the SSH call.

Default: “On droplet {name} at {ip} – Retval={retval} Stdout: {stdout}”

-P, --prelaunch

A python format string to print for each droplet BEFORE launch (for long-running processes). Specify the droplet name and IP as in --format (stdout, stderr, and retval are obviously not available before the thread starts).

Default: “”

-n, --connections

The max number of simultaneous connections (or processes) to make. For actions involving data transfer, set this to something low (probably 1). DEFAULT: 50

Default: 50

-t, --timeout

Max execution time on each droplet in s. No timeout by default.

Default: inf

-r, --reduce

Possible choices: sum, linecount

Specify a function that reduces the STDOUT values, e.g. by summing them.

New commands can be added as bash scripts to llama.dev.dv.SCRIPTS (keep in mind that these run in a non-interactive SSH session, so you will need to initialize your environment accordingly).

These scripts can optionally specify default options (like “–format” below) by putting those arguments in a variable on a new line called “DROPVEC”, e.g. DROPVEC=”–timeout 5 –connections 2”.

A short description of the command can be specified in a variable on a new line called HELP, e.g. HELP=”check running servers”.

Functions to run before and after the vectorized commands (“SETUP” and “CLEANUP” commands, respectively) can be defined using those variables in the command scripts, similarly to DROPVEC. For example, to make a directory called “foo” before any of the vectorized commands run, put SETUP=”mkdir foo” somewhere in the script. To remove that directory afterwards, put CLEANUP=”rm -r foo” somewhere in the script. You can specify multiple SETUP and CLEANUP commands this way; they will be run sequentially as encountered. Environmental variable expansion will be performed on “SETUP” and “CLEANUP” commands in the local environment; specify environmental variables using python format strings. The number of droplets being run on is available in SETUP and CLEANUP scripts as DROPNUM.