More network cleanups that we will try to do

This commit is contained in:
Joshua Harlow 2012-04-26 15:18:25 -07:00
parent 020d370356
commit e3d9712433
3 changed files with 29 additions and 11 deletions

View File

@ -1,14 +1,16 @@
#!/bin/bash
#!/bin/bash -x
# This script cleans up the system as part of a nova uninstall
#
# It is best effort!
#
# There are other scripts in tools/ that might be able to recover it better (but are distro specific)
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root!" 1>&2
exit 1
fi
set -o xtrace
# Set up some good defaults
ENABLED_SERVICES=${ENABLED_SERVICES:-net,vol}
VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
@ -17,8 +19,15 @@ VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
if [[ "$ENABLED_SERVICES" =~ "net" ]]; then
# Ignore any errors from shutting down dnsmasq
service dnsmasq stop || true
service dnsmasq stop
# The above doesn't always work so this way will just incase
for pid in `ps -elf | grep -i dnsmasq | grep nova | perl -le 'while (<>) { my $pid = (split /\s+/)[3]; print $pid; }'`
do
echo "Killing leftover nova dnsmasq process with process id $pid"
kill -9 $pid
done
# Delete rules
iptables -S -v | sed "s/-c [0-9]* [0-9]* //g" | grep "nova" | grep "\-A" | sed "s/-A/-D/g" | awk '{print "iptables",$0}' | bash
@ -37,7 +46,7 @@ fi
if [[ "$ENABLED_SERVICES" =~ "vol" ]]; then
# Logout and delete iscsi sessions
iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | xargs iscsiadm --mode node --logout || true
iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | iscsiadm --mode node --op delete || true
iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | xargs iscsiadm --mode node --logout
iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | iscsiadm --mode node --op delete
fi

View File

@ -471,6 +471,7 @@ class NovaRuntime(NovaMixin, comp.PythonRuntime):
try:
self.virsh.check_virt(virt_type)
self.virsh.restart_service()
LOG.info("Libvirt virtualization type %s seems to be working and running.", colorizer.quote(virt_type))
except exceptions.ProcessExecutionError as e:
msg = ("Libvirt type %r does not seem to be active or configured correctly, "
"perhaps you should be using %r instead: %s" %

View File

@ -7,10 +7,10 @@ echo "Clearing your network up."
if [[ -n `brctl show | grep -i br100` ]]
then
echo "Clearing br100 and making $ETH_SRC be the real interface."
#sudo ifconfig $ETH_SRC down
#sudo ifconfig br100 down
#sudo brctl delif br100 $ETH_SRC
#sudo brctl delbr br100
sudo ifconfig $ETH_SRC down
sudo ifconfig br100 down
sudo brctl delif br100 $ETH_SRC
sudo brctl delbr br100
fi
if [[ -n `brctl show | grep -i virbr0` ]]
@ -20,6 +20,14 @@ then
sudo brctl delbr virbr0
fi
for pid in `ps -elf | grep -i dnsmasq | grep nova | perl -le 'while (<>) { my $pid = (split /\s+/)[3]; print $pid; }'`
do
echo "Killing leftover nova dnsmasq process with process id $pid"
kill -9 $pid
done
if [[ -z `grep "iface $ETH_SRC" /etc/network/interfaces` ]]
then