Thomas Vachuska | e112535 | 2016-11-09 14:06:51 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Checks whether the specified ONOS cluster node has the desired state. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
Jon Hall | fb6009d | 2017-02-15 16:01:17 -0800 | [diff] [blame] | 6 | aux=/tmp/stc/stc-$$.log |
Thomas Vachuska | e112535 | 2016-11-09 14:06:51 -0800 | [diff] [blame] | 7 | trap "rm -f $aux 2>/dev/null" EXIT |
| 8 | |
Jordan Halterman | cbbdb8c | 2017-12-20 18:12:26 -0800 | [diff] [blame] | 9 | function onos_nodes() { |
| 10 | echo $(env | sort | egrep "^OC[0-9]+" | cut -d= -f2) |
| 11 | } |
Thomas Vachuska | e112535 | 2016-11-09 14:06:51 -0800 | [diff] [blame] | 12 | |
Jordan Halterman | cbbdb8c | 2017-12-20 18:12:26 -0800 | [diff] [blame] | 13 | nodes=$(onos_nodes) |
Thomas Vachuska | e112535 | 2016-11-09 14:06:51 -0800 | [diff] [blame] | 14 | |
Jordan Halterman | cbbdb8c | 2017-12-20 18:12:26 -0800 | [diff] [blame] | 15 | for attempt in {1..5}; do |
| 16 | for node in $nodes; do |
| 17 | onos $node "onos:nodes" > $aux |
| 18 | cat $aux |
| 19 | |
| 20 | # Normalize the node status |
| 21 | state=$(grep ${1} $aux | cut -d, -f3 | cut -d= -f2) |
| 22 | |
| 23 | [ "$state" = "${2:-READY}" ] && exit 0 |
| 24 | sleep 1 |
| 25 | done |
Thomas Vachuska | e112535 | 2016-11-09 14:06:51 -0800 | [diff] [blame] | 26 | done |
| 27 | |
| 28 | exit 1 |