blob: 648b32cb326b87c1a04ab10bba7cda7997caa23e [file] [log] [blame]
Scott Baker4746d482016-03-31 14:57:04 -07001source ./config.sh
2
3function lookup_account_num {
4 ID=`curl -f -s -u $AUTH -X GET $HOST/api/tenant/cord/account_num_lookup/$1/`
5 if [[ $? != 0 ]]; then
6 echo "function lookup_account_num with arguments $1 failed" >&2
7 echo "See CURL output below:" >&2
8 curl -s -u $AUTH -X GET $HOST/api/tenant/cord/account_num_lookup/$1/ >&2
9 exit -1
10 fi
11 # echo "(mapped account_num $1 to id $ID)" >&2
12 echo $ID
13}
Scott Baker0b518f62016-03-31 16:13:25 -070014
15function lookup_subscriber_volt {
16 JSON=`curl -f -s -u $AUTH -X GET $HOST/api/tenant/cord/subscriber/$1/`
17 if [[ $? != 0 ]]; then
18 echo "function lookup_subscriber_volt failed to read subscriber with arg $1" >&2
19 echo "See CURL output below:" >&2
20 curl -s -u $AUTH -X GET $HOST/api/tenant/cord/account_num_lookup/$1/ >&2
21 exit -1
22 fi
23 ID=`echo $JSON | python -c "import json,sys; print json.load(sys.stdin)['related'].get('volt_id','')"`
24 if [[ $ID == "" ]]; then
25 echo "there is no volt for this subscriber" >&2
26 exit -1
27 fi
28
29 # echo "(found volt id %1)" >&2
30
31 echo $ID
Scott Bakere4e5a8b2016-04-05 09:56:48 -070032}
33
34function lookup_subscriber_vsg {
35 JSON=`curl -f -s -u $AUTH -X GET $HOST/api/tenant/cord/subscriber/$1/`
36 if [[ $? != 0 ]]; then
37 echo "function lookup_subscriber_vsg failed to read subscriber with arg $1" >&2
38 echo "See CURL output below:" >&2
39 curl -s -u $AUTH -X GET $HOST/api/tenant/cord/account_num_lookup/$1/ >&2
40 exit -1
41 fi
42 ID=`echo $JSON | python -c "import json,sys; print json.load(sys.stdin)['related'].get('vsg_id','')"`
43 if [[ $ID == "" ]]; then
Scott Bakerf0db1252016-04-12 09:07:05 -070044 echo "there is no vsg for this subscriber" >&2
Scott Bakere4e5a8b2016-04-05 09:56:48 -070045 exit -1
46 fi
47
48 # echo "(found vsg id %1)" >&2
49
50 echo $ID
51}
52