clean_loadbalancer.sh 472 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. set -e
  3. LB=$1
  4. if [ -z "$LB" ]; then
  5. echo "Usage: $0 <loadbalancer_id_or_name>"
  6. exit 1
  7. fi
  8. LB_ID=$(climc lb-show $LB | grep -w " id " | awk '{print $4}')
  9. LB_NAME=$(climc lb-show $LB | grep -w " name " | awk '{print $4}')
  10. if [ -z "$LB_ID" ]; then
  11. echo "Loadbalancer $LB not found"
  12. exit 1
  13. fi
  14. echo "Ready to remove loadbalancer $LB_NAME($LB_ID) ..."
  15. clean_loadbalancer() {
  16. local LID=$1
  17. climc lb-purge $LID
  18. }
  19. clean_loadbalancer $LB_ID