blob: ae2889165c510cb037b8999e2fc02dd4c98c3730 [file] [log] [blame]
Thomas Vachuska7772e102014-10-21 09:50:04 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Executes selected set of ONOS commands using the batch mode.
4# -----------------------------------------------------------------------------
5
Ayaka Koshibef17f34a2015-09-24 19:31:48 -07006function _usage () {
7cat << _EOF_
8usage:
9 $(basename $0) [node] <commands>
10
11options:
12- [node] <commands> : node to run <commands>
13
14summary:
15 Executes selected set of ONOS commands using the batch mode.
16
17 <commands> is a comma-separated list of ONOS CLI commands.
18
19 If [node] isn't specified, the defualt target becomes \$OCI. When no commands
20 are specified, the commands 'summary','intents','flows', and 'hosts' are
21 executed against \$OCI.
22
23_EOF_
24}
25
26[ "$1" = "-h" ] && _usage && exit 0
27
Thomas Vachuska7772e102014-10-21 09:50:04 -070028[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
29. $ONOS_ROOT/tools/build/envDefaults
30
31node=${1:-$OCI}
32
33commands="${2:-summary,intents,flows,hosts}"
34
35aux=/tmp/onos-batch.$$
36trap "rm -f $aux" EXIT
37
38echo "$commands" | tr ',' '\n' > $aux
39onos $node -b <$aux