--- /dev/null
+#!/bin/bash
+
+OOM_HOME=${OOM_HOME:-$HOME}
+
+if ! [ "$(command -v jq)" ]; then
+ echo "Error: jq is not installed."
+ echo "use: sudo apt install jq"
+ exit 1
+fi
+
+IS_PRIMARY_CLUSTER=`./sdnc.isPrimaryCluster`
+
+case $IS_PRIMARY_CLUSTER in
+true)
+ MEMBER_NUMBER=1
+ ;;
+false)
+ MEMBER_NUMBER=4
+ ;;
+*)
+ echo "Error: isPrimaryODLCluster not defined in ${OOM_HOME}/oom/kubernetes/sdnc/values.yaml."
+ exit 1
+ ;;
+esac
+
+for pod_number in {0..2}
+do
+ curl "http://localhost:3028$((${pod_number} + 1))" > /dev/null 2>&1
+ if [ "$?" = "7" ]; then
+ continue
+ fi
+
+ VOTING_RESULT=`curl -u admin:admin -H "Content-Type: application/json" -H "Accept: application/json" -X GET http://localhost:3028$((${pod_number} + 1))/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-$((${MEMBER_NUMBER} + ${pod_number}))-shard-default-config,type=DistributedConfigDatastore 2>/dev/null | jq '.value.Voting'`
+
+ case $VOTING_RESULT in
+ true)
+ echo "active"
+ exit 0
+ ;;
+ false)
+ echo "standby"
+ exit 0
+ ;;
+ *)
+ echo "Error: Voting status could not be determined."
+ exit 1
+ ;;
+ esac
+done
+
+echo "Error: Voting status could not be determined."
+exit 1
--- /dev/null
+#!/usr/bin/perl -s\r
+use strict;\r
+\r
+my $keyWord_standby = "standby";\r
+my $keyWord_active = "active";\r
+my $keyWord_true = "true";\r
+my $keyWord_false = "false";\r
+my $keyWord_success = "success";\r
+my $keyWord_failure = "failure";\r
+my $file_cluster = "sdnc.cluster";\r
+my $file_switchVoting = "switchVoting.sh";\r
+my $file_isPrimaryCluster = "sdnc.isPrimaryCluster";\r
+\r
+if ((!(-e $file_cluster)) || (!(-e $file_switchVoting))|| (!(-e $file_isPrimaryCluster))) {\r
+ # file not exist.\r
+ print qq|$keyWord_failure\n|;\r
+ exit 1;\r
+}\r
+\r
+my $roleRes = qx("./$file_isPrimaryCluster");\r
+my $clusterRes = qx("./$file_cluster");\r
+\r
+if ( index ($clusterRes, $keyWord_standby) != -1) {\r
+ # We are at standby side\r
+ if ( index ($roleRes, $keyWord_false) != -1) {\r
+ # We are at Secondary cluster\r
+ sub_activate_secondary();\r
+ } elsif ( index ($roleRes, $keyWord_true) != -1) {\r
+ # We are at Primary cluster\r
+ sub_activate_primary();\r
+ } else {\r
+ # Error.\r
+ print qq|$keyWord_failure\n|;\r
+ exit 1; \r
+ } \r
+} elsif ( index ($clusterRes, $keyWord_active) != -1) {\r
+ # We are at active side \r
+ if ( index ($roleRes, $keyWord_false) != -1) {\r
+ # We are at Secondary cluster\r
+ sub_activate_primary();\r
+ } elsif ( index ($roleRes, $keyWord_true) != -1) {\r
+ # We are at Primary cluster\r
+ sub_activate_secondary();\r
+ } else {\r
+ # Error.\r
+ print qq|$keyWord_failure\n|;\r
+ exit 1; \r
+ } \r
+} else {\r
+ # Error.\r
+ print qq|$keyWord_failure\n|;\r
+ exit 1; \r
+}\r
+\r
+sub sub_activate_primary {\r
+ #Switching voting in Primary cluster \r
+ system("./$file_switchVoting primary");\r
+ print qq|$keyWord_success\n|;\r
+}\r
+\r
+sub sub_activate_secondary {\r
+ #Switching voting in secondary cluster\r
+ system("./$file_switchVoting secondary");\r
+ print qq|$keyWord_success\n|;\r
+}\r
--- /dev/null
+#!/bin/bash
+
+function usage()
+{
+ echo usage: switchVoting.sh primary\|secondary
+ exit 1
+}
+
+if [ $# -ne 1 ]; then
+ usage
+fi
+
+partition=$1
+
+if [ "$partition" == "primary" ]; then
+ curl -u admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -H "Content-Type: application/json" -H "Accept: application/json" -X POST http://localhost:30202/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards -d '{ "input" : { "member-voting-state" : [ { "member-name" : "member-1", "voting":true}, { "member-name" : "member-2", "voting":true}, { "member-name" : "member-3", "voting":true},{ "member-name" : "member-4", "voting":false},{ "member-name" : "member-5", "voting":false},{ "member-name" : "member-6", "voting":false}] } }' > switch_voting_resp.json 2>/dev/null
+ echo "" >> switch_voting_resp.json
+ exit 0
+fi
+
+if [ "$partition" == "secondary" ]; then
+ curl -u admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -H "Content-Type: application/json" -H "Accept: application/json" -X POST http://localhost:30202/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards -d '{ "input" : { "member-voting-state" : [ { "member-name" : "member-1", "voting":false}, { "member-name" : "member-2", "voting":false}, { "member-name" : "member-3", "voting":false},{ "member-name" : "member-4", "voting":true},{ "member-name" : "member-5", "voting":true},{ "member-name" : "member-6", "voting":true}] } }' > switch_voting_resp.json 2>/dev/null
+ echo "" >> switch_voting_resp.json
+ exit 0
+fi
+
+usage