blob: 8dd84bd3eac23971920be4bcdfe48042690912ea [file] [log] [blame]
Mohammadreza Pasandidehb642ee52018-06-19 15:19:53 -04001#!/bin/bash
2
3# Copyright © 2018 Amdocs
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17debugLog(){
18 if [ "$enableDebugLogging" == true ]; then
19 if [ $# -eq 0 ]; then
20 echo "" >> $LOGFILE
21 else
22 echo $( date ) $@ >> $LOGFILE
23 fi
24 fi
25}
26
27LOGFILE="/app/geo.log"
28enableDebugLogging=true
29
30debugLog
31debugLog "Executing ensureSdncStandby"
32
33# query SDN-C cluster status
34debugLog "Started executing sdnc.cluster"
35clusterStatus=$( /app/bin/sdnc.cluster )
36debugLog "Completed executing sdnc.cluster. Cluster status is: $clusterStatus"
37
38if [ "active" = "$clusterStatus" ]; then
39 # assume transient error as other side transitions to ACTIVE
40 debugLog "Cluster status: $clusterStatus. exit 0"
41 exit 0
42
43elif [ "standby" = "$clusterStatus" ]; then
44 # check that standby cluster is healthy
45 debugLog "Started executing sdnc.monitor. Cluster status is: $clusterStatus"
46 health=$( /app/bin/sdnc.monitor )
47 debugLog "Completed executing sdnc.monitor. Cluster is: $health"
48 if [ "failure" = "$health" ];then
49 # Backup site is unhealthy - can't accept traffic!
50 exit 1
51 fi
52 # Cluster is standing by
53 exit 0
54fi
55
56debugLog "Unknown cluster status: $clusterStatus"
57# Unknown cluster status
58exit 1