| # ----------------------------------------------------------------------------- |
| # Executes a command on all ONOS instances in a cluster and matches the output |
| # from each instance to the passed one. |
| # First argument is the command and it's arguments if needed, then --expect and |
| # after it the string of what the output should be. |
| # onos-cluster-execute-expect fooCommand fooParamenter --expect fooOutputString |
| # ----------------------------------------------------------------------------- |
| [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| . $ONOS_ROOT/tools/build/envDefaults |
| trap "rm -f $aux 2>/dev/null" EXIT |
| for a in ${*:1}; do shift; if [ "$a" = "--expect" ]; then break; fi; cmd="$cmd $a"; done |
| nodes=`onos $OCI nodes | awk -F 'address=' '{print $2}' | cut -d':' -f1` |
| onos ${node_var} $cmd > $aux |
| grep -q $expect $aux || exit 1 |
| echo "expected value found" |