blob: a2ad1c989fab4e0481688efdca998e78515ecd28 [file] [log] [blame]
Claudine Chiu0005a4d2016-05-25 12:13:43 -04001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Checks vnet related entities (tenantId, networkId).
4# -----------------------------------------------------------------------------
5
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
9aux=/tmp/stc-$$.log
10trap "rm -f $aux 2>/dev/null" EXIT
11target=${1:-$OCI}
12command_name=`basename $0`
13
14# Prints usage help
15function usage {
16 echo "usage: $command_name <node-ip> checkTenant <tenantId>" >&2
17 echo " $command_name <node-ip> getNetworkId <tenantId>" >&2
18}
19
20# Extracts networkId
21function extractAndPublishNetworkId() {
22 for token in $aString
23 do
24 if [[ $token =~ "networkId=" ]]
25 then
26 echo "@stc $token"
27 exit 0
28 fi
29 done
30 return 1
31}
32
33echo $command_name: $*
34[ $# -lt 3 ] || [ "$1" = "-h" ] && usage && exit 0
35
36case "$2" in
37 "checkTenant")
38 onos $target "vnet-tenants" | tee $aux
39 grep -w $3 $aux && exit 0
40 ;;
41 "getNetworkId")
42 onos $target "vnets" | tee $aux
43 aString=`grep "tenantId=$3," $aux | tail -1` #get last row
44 extractAndPublishNetworkId && exit 0
45 ;;
46 *)
47 usage
48 ;;
49esac
50
51cat $aux
52exit 1
53