Ray Milkey | 5d35f9c | 2018-04-02 08:54:51 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Finds a host in the system. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
| 9 | aux=/tmp/stc/stc-$$.log |
| 10 | trap "rm -f $aux 2>/dev/null" EXIT |
| 11 | |
| 12 | echo onos-find-host: $* |
| 13 | |
| 14 | target=${1:-$OCI} |
| 15 | mac=$2 |
| 16 | locations=$3 |
| 17 | ips=$4 |
| 18 | set -x |
| 19 | |
| 20 | onos $target "onos:hosts" | tee $aux |
| 21 | cat $aux | fgrep "mac=$mac" | fgrep "locations=[$locations]" | grep "ip.*[.*$ips.*]" |
| 22 | |
| 23 | if [ $? -ne 0 ] |
| 24 | then |
| 25 | exit 1; |
| 26 | fi |
| 27 | |
| 28 | exit 0 |
| 29 | |