Skip to content

Instantly share code, notes, and snippets.

@carlosedp
Created June 1, 2017 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosedp/f2dc8e184ed8cafb6fc71013f0d37bff to your computer and use it in GitHub Desktop.
Save carlosedp/f2dc8e184ed8cafb6fc71013f0d37bff to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set the lb id
LB_ID=$1
read -p "Do you really want to delete LB \"${LB_ID}\"? " -n 1 -r
echo # new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
listeners=($(neutron lbaas-loadbalancer-show ${LB_ID} --format json |grep listeners| grep -o '[a-f0-9-]\{36\}'))
pools=($(neutron lbaas-loadbalancer-show ${LB_ID} --format json |grep pools| grep -o '[a-f0-9-]\{36\}'))
health=($(neutron lbaas-loadbalancer-show ${LB_ID} --format json |grep healthmonitor_id| grep -o '[a-f0-9-]\{36\}'))
for i in ${health[@]}
do
echo "Deleting healthmonitor $i"
neutron lbaas-healthmonitor-delete "$i"
done
for i in ${pools[@]}
do
echo "Deleting pool $i"
neutron lbaas-pool-delete "$i"
done
for i in ${listeners[@]}
do
echo "Deleting listener $i"
neutron lbaas-listener-delete "$i"
done
echo "Deleting loadbalancer ${LB_ID}"
neutron lbaas-loadbalancer-delete "${LB_ID}"
echo "Done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment