4 # Copyright © 2018 Amdocs
5 # Modifications Copyright © 2018 AT&T
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 # query ODL cluster state
21 USERNAME="{{.Values.odl.jolokia.username}}"
22 PASSWORD="{{.Values.odl.jolokia.password}}"
24 count=${SDNC_ODL_COUNT:-1}
26 if [ "$SDNC_IS_PRIMARY_CLUSTER" = "false" ];then
30 for instance in $(seq $count);do
31 shard=member-$(( $siteId*$count + $instance ))-shard-default-config
32 mbean=Category=Shards,name=$shard,type=DistributedConfigDatastore
33 url=http://{{ include "common.release" . }}-sdnc-$(( $instance-1 )).sdnc-cluster.{{.Release.Namespace}}:8181/jolokia/read/org.opendaylight.controller:$mbean
35 response=$( curl -s -u $USERNAME:$PASSWORD $url )
38 # failed to contact SDN-C instance - try another
39 echo "Unable to connect to $shard [rc=$?]"
43 status=$( echo "$response" | jq -r ".status" )
44 if [ "$status" != "200" ];then
45 # query failed, try another instance
46 echo "$shard query failed [http-status=$status]"
50 raftState=$( echo "$response" | jq -r ".value.RaftState" )
51 if [ "$raftState" = "Leader" -o "$raftState" = "Follower" ];then
52 # cluster has a leader and is healthy
53 echo "$shard is healthy [RaftState=$raftState]"
56 echo "$shard is not healthy [RaftState=$raftState]"
60 # ODL cluster is not healthy