blob: 0cd4688968ce00450f45fef3e76dd6b0365d8191 [file] [log] [blame]
Thomas Vachuskae1125352016-11-09 14:06:51 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Checks whether the specified ONOS cluster node has the desired state.
4# -----------------------------------------------------------------------------
5
Jon Hallfb6009d2017-02-15 16:01:17 -08006aux=/tmp/stc/stc-$$.log
Thomas Vachuskae1125352016-11-09 14:06:51 -08007trap "rm -f $aux 2>/dev/null" EXIT
8
Jordan Haltermandd0e04c2017-12-20 18:12:26 -08009function onos_nodes() {
10 echo $(env | sort | egrep "^OC[0-9]+" | cut -d= -f2)
11}
Thomas Vachuskae1125352016-11-09 14:06:51 -080012
Jordan Haltermandd0e04c2017-12-20 18:12:26 -080013nodes=$(onos_nodes)
Thomas Vachuskae1125352016-11-09 14:06:51 -080014
Jordan Haltermandd0e04c2017-12-20 18:12:26 -080015for 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 Vachuskae1125352016-11-09 14:06:51 -080026done
27
28exit 1