summaryrefslogtreecommitdiffstats
path: root/kubernetes/sdnc/resources/geo/bin/sdnc.failover
diff options
context:
space:
mode:
authorNeha Jain <neha.jain3@amdocs.com>2018-04-05 11:51:29 -0400
committerNeha Jain <neha.jain3@amdocs.com>2018-04-05 11:51:35 -0400
commitde45c68c288c44af517d4a403b8a154a715df555 (patch)
tree7b6c2662d129094f4b01cf4293753893c8f8f3b6 /kubernetes/sdnc/resources/geo/bin/sdnc.failover
parent283a3d9cbb7e9d18294bfaa6f67f980880e57d4a (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.failover')
-rwxr-xr-xkubernetes/sdnc/resources/geo/bin/sdnc.failover65
1 files changed, 65 insertions, 0 deletions
diff --git a/kubernetes/sdnc/resources/geo/bin/sdnc.failover b/kubernetes/sdnc/resources/geo/bin/sdnc.failover
new file mode 100755
index 0000000000..961a5cb5cf
--- /dev/null
+++ b/kubernetes/sdnc/resources/geo/bin/sdnc.failover
@@ -0,0 +1,65 @@
+#!/usr/bin/perl -s
+use strict;
+
+my $keyWord_standby = "standby";
+my $keyWord_active = "active";
+my $keyWord_true = "true";
+my $keyWord_false = "false";
+my $keyWord_success = "success";
+my $keyWord_failure = "failure";
+my $file_cluster = "sdnc.cluster";
+my $file_switchVoting = "switchVoting.sh";
+my $file_isPrimaryCluster = "sdnc.isPrimaryCluster";
+
+if ((!(-e $file_cluster)) || (!(-e $file_switchVoting))|| (!(-e $file_isPrimaryCluster))) {
+ # file not exist.
+ print qq|$keyWord_failure\n|;
+ exit 1;
+}
+
+my $roleRes = qx("./$file_isPrimaryCluster");
+my $clusterRes = qx("./$file_cluster");
+
+if ( index ($clusterRes, $keyWord_standby) != -1) {
+ # We are at standby side
+ if ( index ($roleRes, $keyWord_false) != -1) {
+ # We are at Secondary cluster
+ sub_activate_secondary();
+ } elsif ( index ($roleRes, $keyWord_true) != -1) {
+ # We are at Primary cluster
+ sub_activate_primary();
+ } else {
+ # Error.
+ print qq|$keyWord_failure\n|;
+ exit 1;
+ }
+} elsif ( index ($clusterRes, $keyWord_active) != -1) {
+ # We are at active side
+ if ( index ($roleRes, $keyWord_false) != -1) {
+ # We are at Secondary cluster
+ sub_activate_primary();
+ } elsif ( index ($roleRes, $keyWord_true) != -1) {
+ # We are at Primary cluster
+ sub_activate_secondary();
+ } else {
+ # Error.
+ print qq|$keyWord_failure\n|;
+ exit 1;
+ }
+} else {
+ # Error.
+ print qq|$keyWord_failure\n|;
+ exit 1;
+}
+
+sub sub_activate_primary {
+ #Switching voting in Primary cluster
+ system("./$file_switchVoting primary");
+ print qq|$keyWord_success\n|;
+}
+
+sub sub_activate_secondary {
+ #Switching voting in secondary cluster
+ system("./$file_switchVoting secondary");
+ print qq|$keyWord_success\n|;
+}