summaryrefslogtreecommitdiff
path: root/tools/cleanup-containers
blob: 57c663c9cd0c9c0a16ebb7b5a27994c168782483 (plain)
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
32
33
34
35
36
37
38
39
#!/bin/bash

# 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