Thomas Vachuska | 7772e10 | 2014-10-21 09:50:04 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Executes selected set of ONOS commands using the batch mode. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
Ayaka Koshibe | f17f34a | 2015-09-24 19:31:48 -0700 | [diff] [blame] | 6 | function _usage () { |
| 7 | cat << _EOF_ |
| 8 | usage: |
| 9 | $(basename $0) [node] <commands> |
| 10 | |
| 11 | options: |
| 12 | - [node] <commands> : node to run <commands> |
| 13 | |
| 14 | summary: |
| 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 Vachuska | 7772e10 | 2014-10-21 09:50:04 -0700 | [diff] [blame] | 28 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 29 | . $ONOS_ROOT/tools/build/envDefaults |
| 30 | |
| 31 | node=${1:-$OCI} |
| 32 | |
| 33 | commands="${2:-summary,intents,flows,hosts}" |
| 34 | |
| 35 | aux=/tmp/onos-batch.$$ |
| 36 | trap "rm -f $aux" EXIT |
| 37 | |
| 38 | echo "$commands" | tr ',' '\n' > $aux |
| 39 | onos $node -b <$aux |