diff options
author | Neha Jain <neha.jain3@amdocs.com> | 2018-04-05 11:51:29 -0400 |
---|---|---|
committer | Neha Jain <neha.jain3@amdocs.com> | 2018-04-05 11:51:35 -0400 |
commit | de45c68c288c44af517d4a403b8a154a715df555 (patch) | |
tree | 7b6c2662d129094f4b01cf4293753893c8f8f3b6 /kubernetes/sdnc/resources/geo/bin/sdnc.cluster | |
parent | 283a3d9cbb7e9d18294bfaa6f67f980880e57d4a (diff) |
Multi-site High-availability Manual Failover (PoC)
Change-Id: I0d5644790441099434322d486f4ba014fd8bc1f7
Signed-off-by: Neha Jain <neha.jain3@amdocs.com>
Issue-ID: SDNC-214
Diffstat (limited to 'kubernetes/sdnc/resources/geo/bin/sdnc.cluster')
-rwxr-xr-x | kubernetes/sdnc/resources/geo/bin/sdnc.cluster | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/kubernetes/sdnc/resources/geo/bin/sdnc.cluster b/kubernetes/sdnc/resources/geo/bin/sdnc.cluster new file mode 100755 index 0000000000..d59718fa27 --- /dev/null +++ b/kubernetes/sdnc/resources/geo/bin/sdnc.cluster @@ -0,0 +1,52 @@ +#!/bin/bash + +OOM_HOME=${OOM_HOME:-$HOME} + +if ! [ "$(command -v jq)" ]; then + echo "Error: jq is not installed." + echo "use: sudo apt install jq" + exit 1 +fi + +IS_PRIMARY_CLUSTER=`./sdnc.isPrimaryCluster` + +case $IS_PRIMARY_CLUSTER in +true) + MEMBER_NUMBER=1 + ;; +false) + MEMBER_NUMBER=4 + ;; +*) + echo "Error: isPrimaryODLCluster not defined in ${OOM_HOME}/oom/kubernetes/sdnc/values.yaml." + exit 1 + ;; +esac + +for pod_number in {0..2} +do + curl "http://localhost:3026$((${pod_number} + 1))" > /dev/null 2>&1 + if [ "$?" = "7" ]; then + continue + fi + + 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'` + + case $VOTING_RESULT in + true) + echo "active" + exit 0 + ;; + false) + echo "standby" + exit 0 + ;; + *) + echo "Error: Voting status could not be determined." + exit 1 + ;; + esac +done + +echo "Error: Voting status could not be determined." +exit 1 |