aboutsummaryrefslogtreecommitdiffstats
path: root/sampleApp/ensureSdncActive.sh
blob: 70202c85e3077894ba60af50a4d96a7e03a6ef6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

dir=`dirname $0`
# query SDN-C cluster status
clusterStatus=$( $dir/sdnc.cluster )

if [ "ACTIVE" = "$clusterStatus" ];then
  # peform health-check
  health=$( $dir/sdnc.monitor )
  
  if [ "HEALTHY" = "$health" ]; then
    echo "Cluster is ACTIVE and HEALTHY"
    exit 0
  fi
  echo "Cluster is ACTIVE and UNHEALTHY"
  exit 1

elif [ "STANDBY" = "$clusterStatus" ]; then
  # perform takeover
  echo "Cluster is STANDBY - taking over"
  takeoverResult=$( $dir/sdnc.failover )
  if [ "SUCCESS" = "$takeoverResult" ]; then
    exit 0
  fi
  echo "Cluster takeover failed"
  exit 1
fi

echo "Unknown cluster status '$clusterStatus'"
exit 1