Created
December 4, 2015 23:48
-
-
Save SVilgelm/d7f946017b71e2f69923 to your computer and use it in GitHub Desktop.
Clean all network resources from neutron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function get_ids { | |
echo `$@ --fields=id | tail -n+4 | head -n-1 | awk '{ print $2 }'` | |
} | |
function get_body { | |
echo `$@ | tail -n+4 | head -n-1` | |
} | |
INSTANCES=$(get_ids nova list) | |
if [ -n "$INSTANCES" ]; then | |
nova delete $INSTANCES | |
fi | |
for id in $(get_ids neutron floatingip-list); do | |
neutron floatingip-delete $id | |
done | |
for router_id in $(get_ids neutron router-list); do | |
neutron router-gateway-clear $router_id | |
for subnet_id in $(get_body neutron router-port-list $router_id | cut -d'"' -f4); do | |
neutron router-interface-delete $router_id $subnet_id | |
done | |
neutron router-delete $router_id | |
done | |
for net_id in $(get_ids neutron net-list); do | |
for port_id in $(get_ids neutron port-list --network-id=$net_id); do | |
neutron port-delete $port_id | |
done | |
neutron net-delete $net_id | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment