-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathds-network-cleanup
More file actions
executable file
·31 lines (22 loc) · 972 Bytes
/
ds-network-cleanup
File metadata and controls
executable file
·31 lines (22 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
set -x
if [ -n "$1" ]; then
regex=$1
else
regex=vip
fi
openstack floating ip list -f value | cut -d' ' -f1 | xargs -n1 -r openstack floating ip delete
openstack router list -f value | grep $regex | cut -d' ' -f1 | xargs -n1 -r openstack router unset --external-gateway
for router in $(openstack router list -f value | grep $regex | cut -d' ' -f1); do
for subnet in $(openstack router show -c interfaces_info -f value $router | sed -e 's/},/\n/g' | sed -e "s/.*'subnet_id': '\([a-f0-9-]*\)'.*/\1/g"); do
openstack router remove subnet $router $subnet
done
done
openstack router list -f value | grep $regex | cut -d' ' -f1 | xargs -n1 -r openstack router delete
for network in $(openstack network list -f value | grep $regex | cut -d' ' -f1); do
for port in $(openstack port list -f value -c ID --network $network); do
echo $port
openstack port delete $port
done
openstack network delete $network
done