| #!/bin/bash |
| # ----------------------------------------------------------------------------- |
| # Checks whether the specified ONOS cluster node has the desired state. |
| # ----------------------------------------------------------------------------- |
| |
| aux=/tmp/stc/stc-$$.log |
| trap "rm -f $aux 2>/dev/null" EXIT |
| |
| function onos_nodes() { |
| echo $(env | sort | egrep "^OC[0-9]+" | cut -d= -f2) |
| } |
| |
| nodes=$(onos_nodes) |
| |
| for attempt in {1..5}; do |
| for node in $nodes; do |
| onos $node "onos:nodes" > $aux |
| cat $aux |
| |
| # Normalize the node status |
| state=$(grep ${1} $aux | cut -d, -f3 | cut -d= -f2) |
| |
| [ "$state" = "${2:-READY}" ] && exit 0 |
| sleep 1 |
| done |
| done |
| |
| exit 1 |