kolla-ansible/tools/cleanup-host
Eduardo Gonzalez da83802b1b Fix ovs-cleanup issue at cleanup scripts
Move ovs-cleanup step to cleanup-containers,
otherwise bridges will not be removed because neutron_openvswitch_agent
container does not exists after running cleanup-containers.

Add logic to cleanup ovs bridges only when openvswitch_db
is removed and openvswitch-agent is running,
so when removing other container from a parameter at script
invocation ovs-cleanup will not be executed.

Change-Id: Ie5fea40426df0e9e465fc173aba185f61098f676
Closes-Bug: #1640178
2016-12-30 14:10:30 +01:00

61 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# Move to top level directory
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
. tools/validate-docker-execute.sh
# Spawning the neutron agents containers leaves artifacts on the host.
# This script removes these artifacts.
ip netns list | while read -r line ; do
echo "Removing network namespace $line on the host"
ip netns delete $line
done
ip -o link show | awk -F': ' '/tap/{print $2}' | while read -r ifname ; do
echo "Removing tap interface $ifname on the host"
ip link delete $ifname type veth
done
ip -o link show | awk -F': ' '/brq/{print $2}' | while read -r ifname ; do
echo "Removing linux bridge $ifname on the host"
ip link delete $ifname type bridge
done
ip -o link show | awk -F': ' '/vxlan/{print $2}' | while read -r ifname ; do
echo "Removing vxlan interface $ifname on the host"
ip link delete $ifname type vxlan
done
# Keepalived leaves VIP on the host in case of accidental removal.
# This snippet removes VIPs.
if [[ "$enable_haproxy" == "yes" ]]; then
ip -o addr list | awk '{print $2,$4}' | cut -d/ -f1 | while read -r ifname ifaddr ; do
if [[ "$kolla_internal_vip_address" == "$ifaddr" ||
"$kolla_external_vip_address" == "$ifaddr" ]]; then
echo "Removing VIP $ifaddr on the host"
ip addr delete dev $ifname $ifaddr
fi
done
fi
echo "Creating a fstab backup..."
sudo cp /etc/fstab /etc/fstab_backup
echo "Removing ceph references from fstab..."
sudo sed -i '/\/var\/lib\/ceph\/osd\//d' /etc/fstab
echo "Getting folders name..."
FOLDER_PATH="/etc/kolla/"
for dir in $FOLDER_PATH*; do
if [ "$dir" == "$FOLDER_PATH""passwords.yml" ] || \
[ "$dir" == "$FOLDER_PATH""globals.yml" ] || \
[ "$dir" == "$FOLDER_PATH""kolla-build.conf" ] || \
[ "$dir" == "$FOLDER_PATH""config" ]; then
echo "Skipping:" $dir
else
rm -rfv $dir
fi
done