diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-05-08 16:01:51 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-05-08 16:01:51 +0000 |
| commit | 56e72a6bcf1f06081d5513c79080436001c2afcc (patch) | |
| tree | b42a6c56550f77321b57ee21e1fa87d3911e31e6 | |
| parent | 08f9553339efdeb76f262c8a25a341dcaad5ee6c (diff) | |
| parent | 556388e7370d467acf89b248fb37159beef61b74 (diff) | |
| download | kolla-56e72a6bcf1f06081d5513c79080436001c2afcc.tar.gz kolla-56e72a6bcf1f06081d5513c79080436001c2afcc.zip | |
Merge "Updates cleanup-containers"
| -rwxr-xr-x | tools/cleanup-containers | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tools/cleanup-containers b/tools/cleanup-containers index 7b0e8341e..57c663c9c 100755 --- a/tools/cleanup-containers +++ b/tools/cleanup-containers @@ -1,3 +1,39 @@ #!/bin/bash -docker rm $@ $(docker ps -a -q) +# Check if user is root +if [[ $EUID -ne 0 ]]; then + echo "You must execute this script as root." 1>&2 + exit 1 +fi + +# Move to top level directory +REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')") +cd "$(dirname "$REAL_PATH")/.." + +# Remove docker containers +docker ps -a -q | while read -r line ; do + echo "Removing docker containers" + docker rm -f $line +done + +# Spawning the neutron-agents container leaves artifacts on the host. +# This script removes these artifacts. +ip netns list | while read -r line ; do + echo "Removing network namespaces on the host" + ip netns delete $line +done + +ifconfig | grep tap | awk '{print $1;}'| cut -f1 -d':' | while read -r line ; do + echo "Removing tap interfaces on the host" + ip link delete $line type veth +done + +ifconfig | grep brq | awk '{print $1;}'| cut -f1 -d':' | while read -r line ; do + echo "Removing linux bridges on the host" + ip link delete $line type bridge +done + +ifconfig | grep vxlan | awk '{print $1;}'| cut -f1 -d':' | while read -r line ; do + echo "Removing vxlan interfaces on the host" + ip link delete $line type vxlan +done |
