aboutsummaryrefslogtreecommitdiffstats
path: root/sampleApp/ensureSdncStandby.sh
blob: b9e9864e331a1946eac28885d8b3ca93c5ef72e4 (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
#!/bin/bash

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

if [ "ACTIVE" = "$clusterStatus" ];then
  # check that standby cluster is healthy
  health=$( $dir/sdnc.monitor )
  if [ "FAILURE" = "$health" ];then
    echo "Backup site is unhealthy - can't accept traffic!"
    exit 1
  fi

  # assume transient error as other side transitions to ACTIVE
  echo "Cluster is ACTIVE but PROM wants STANDBY! Panic!"
  exit 0

elif [ "STANDBY" = "$clusterStatus" ]; then
  echo "Cluster is standing by"
  exit 0
fi

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