aboutsummaryrefslogtreecommitdiffstats
path: root/sampleApp/ensureSdncActive.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sampleApp/ensureSdncActive.sh')
-rwxr-xr-xsampleApp/ensureSdncActive.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/sampleApp/ensureSdncActive.sh b/sampleApp/ensureSdncActive.sh
new file mode 100755
index 0000000..70202c8
--- /dev/null
+++ b/sampleApp/ensureSdncActive.sh
@@ -0,0 +1,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