blob: d59718fa27caae235cfa92e196479d0c7e9b3784 [file] [log] [blame]
Neha Jainde45c682018-04-05 11:51:29 -04001#!/bin/bash
2
3OOM_HOME=${OOM_HOME:-$HOME}
4
5if ! [ "$(command -v jq)" ]; then
6 echo "Error: jq is not installed."
7 echo "use: sudo apt install jq"
8 exit 1
9fi
10
11IS_PRIMARY_CLUSTER=`./sdnc.isPrimaryCluster`
12
13case $IS_PRIMARY_CLUSTER in
14true)
15 MEMBER_NUMBER=1
16 ;;
17false)
18 MEMBER_NUMBER=4
19 ;;
20*)
21 echo "Error: isPrimaryODLCluster not defined in ${OOM_HOME}/oom/kubernetes/sdnc/values.yaml."
22 exit 1
23 ;;
24esac
25
26for pod_number in {0..2}
27do
28 curl "http://localhost:3026$((${pod_number} + 1))" > /dev/null 2>&1
29 if [ "$?" = "7" ]; then
30 continue
31 fi
32
33 VOTING_RESULT=`curl -u admin:admin -H "Content-Type: application/json" -H "Accept: application/json" -X GET http://localhost:3026$((${pod_number} + 1))/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-$((${MEMBER_NUMBER} + ${pod_number}))-shard-default-config,type=DistributedConfigDatastore 2>/dev/null | jq '.value.Voting'`
34
35 case $VOTING_RESULT in
36 true)
37 echo "active"
38 exit 0
39 ;;
40 false)
41 echo "standby"
42 exit 0
43 ;;
44 *)
45 echo "Error: Voting status could not be determined."
46 exit 1
47 ;;
48 esac
49done
50
51echo "Error: Voting status could not be determined."
52exit 1