#!/bin/bash source /etc/kolla/admin-openrc.sh function show_lb_owner() { LB_ID=$1 # show project PROJECT_ID=$(openstack loadbalancer show -c project_id -f value ${LB_ID}) PROJECT_NAME=$(openstack project show -c name -f value ${PROJECT_ID}) # show domain DOMAIN_ID=$(openstack project show -c domain_id -f value ${PROJECT_ID}) DOMAIN_NAME=$(openstack domain show -c name -f value ${DOMAIN_ID}) echo "Domain: ${DOMAIN_NAME}" echo "Project: ${PROJECT_NAME}" } EXIT_CODE=0 # list broken LB OUTPUT="$(openstack loadbalancer amphora list --provisioning-status ERROR)" if [ -n "${OUTPUT}" ]; then echo "${OUTPUT}" EXIT_CODE=1 fi # search for broken LB for LB_ID in $(openstack loadbalancer amphora list --provisioning-status ERROR -c loadbalancer_id -f value | uniq | grep -v None); do # show LB details CMD="openstack loadbalancer show ${LB_ID}" echo "${CMD}" ${CMD} # show LB VMs details CMD="openstack loadbalancer amphora list --loadbalancer ${LB_ID}" echo "${CMD}" ${CMD} # show LB owner show_lb_owner ${LB_ID} echo EXIT_CODE=1 done # search for single amphora VMs for LB_ID in $(openstack loadbalancer list -c id -f value); do if [ $(openstack loadbalancer amphora list --loadbalancer ${LB_ID} -f value | wc -l) -ne 2 ]; then # openstack loadbalancer amphora list --provisioning-status ERROR # openstack loadbalancer amphora list --role STANDALONE echo "Single amphora VM:" CMD="openstack loadbalancer amphora list --loadbalancer ${LB_ID}" echo "${CMD}" ${CMD} # show LB details CMD="openstack loadbalancer show ${LB_ID}" echo "${CMD}" ${CMD} # show LB owner show_lb_owner ${LB_ID} echo EXIT_CODE=1 fi done # check amphora VM count LB_COUNT=$(openstack loadbalancer list -f value | wc -l) LB_AMPHORA_COUNT=$(openstack loadbalancer amphora list --status ALLOCATED -f value | wc -l) if [ $((LB_COUNT*2)) -ne ${LB_AMPHORA_COUNT} ]; then echo "Wrong Amphora VM count: expected: $((LB_COUNT*2)), found: ${LB_AMPHORA_COUNT}" echo EXIT_CODE=1 fi # Check running amphora VMs openstack server list --all-projects --name amphora -c Name -f value | cut -d "-" -f2- | sort > /tmp/amphora_vms openstack loadbalancer amphora list -f json | jq -r '.[] | select(.status == "READY" or .status == "ALLOCATED").id' | sort > /tmp/amphora_lb OUTPUT="$(diff /tmp/amphora_vms /tmp/amphora_lb)" if [ -n "${OUTPUT}" ]; then echo "${OUTPUT}" EXIT_CODE=1 fi # show pending update # openstack loadbalancer list --provisioning-status PENDING_UPDATE -c id -f value | xargs -L1 openstack loadbalancer show -c updated_at -c provisioning_status -c id -c name # send notification echo exit ${EXIT_CODE}